Bug 492106 - The height of text in LSP plugin popup boxes is not always determined correctly, leading to scrollbars being created when not needed
Summary: The height of text in LSP plugin popup boxes is not always determined correct...
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: general (show other bugs)
Version: Git
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-08-23 22:18 UTC by Adam Fontenot
Modified: 2024-08-24 08:04 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
screenshot of the issue (19.50 KB, image/png)
2024-08-23 22:18 UTC, Adam Fontenot
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Fontenot 2024-08-23 22:18:58 UTC
Created attachment 172896 [details]
screenshot of the issue

SUMMARY

See screenshot for example. Sometimes the box doesn't set its height correctly, leading to forced scrollbars.

I think I tracked down at least part of the issue:

The popup box code sizes the box to either 1/3 of the view height, or the following value, whichever is less:

    const int height = fm.lineSpacing() * (document()->lineCount());

If I'm reading this right it gets the height in pixels of lines in the chosen font, using the font metrics, and multiplies it by the number of lines in the document being inserted into the popup.

This doesn't work because the documents displayed in these popups are not plain text! They're converted from Markdown, so are probably HTML (?), but regardless they contain elements that have more height than a line of text in the user's font. For example, a bunch of the responses from rust-analyzer have a "-----------" horizontal rule, which have slightly larger margins. And Kate also renders the "#" h1, h2 headers in a much larger font which uses more space. I'm also not sure how it deals with paragraph breaks - just in general, the text height of Markdown source isn't a very good predictor of the height of a rendered document.

This leads to awkwardly needing to scroll to see one or two lines of text at the bottom of the popup, even though the normal size of a popup would easily accommodate the text.

Tested against latest Git but also observed with 24.08.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 6.1.4
KDE Frameworks Version: 6.5.0
Qt Version: 6.7.2
Kernel Version: 6.10.5-arch1-1 (64-bit)
Graphics Platform: Wayland
Comment 1 Bug Janitor Service 2024-08-24 02:04:49 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/kate/-/merge_requests/1566