Bug 492062 - the LSP plugin doesn't set an appropriate size for the language server popup box
Summary: the LSP plugin doesn't set an appropriate size for the language server popup box
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: general (other bugs)
Version First Reported In: 24.08.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-08-23 04:40 UTC by Adam Fontenot
Modified: 2024-08-23 18:24 UTC (History)
1 user (show)

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


Attachments
screenshot of the issue (45.61 KB, image/png)
2024-08-23 04:40 UTC, Adam Fontenot
Details
screenshot of issue with large window size (190.68 KB, image/png)
2024-08-23 13:49 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 04:40:06 UTC
Created attachment 172867 [details]
screenshot of the issue

SUMMARY

When I'm using the LSP plugin, the popup starts to appear and get sized right before all of the text response for the language server has come in. This means that the LSP plugin frequently makes the box slightly to small to avoid scrolling (especially horizontal scrolling), which is extremely annoying.

The incorrect box size also seems to cause soft wrapping of language server results that already *hard* wrapped - making them very difficult to read.

Another side effect of this is that if you hover over something, move the cursor off, then move back a second later, you might get a box with a *completely* different size, which is pretty jarring.


STEPS TO REPRODUCE
1. Hover over some common types like Strings with the rust-analyzer plugin enabled.

OBSERVED RESULT

See summary and attached screenshot.


EXPECTED RESULT

The box should pick a size that is reasonable. 

Hard wrapped text should never be shown. If the text is soft wrapped, then you never need to show a horizontal scrollbar in a small popup box, which is a really good thing.

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 Waqar Ahmed 2024-08-23 08:06:31 UTC
Git commit 9683da08798b327b8d41d80123a6773e9246821c by Waqar Ahmed.
Committed on 23/08/2024 at 08:05.
Pushed by waqar into branch 'master'.

Dont insert line breaks in tooltip

M  +0    -1    apps/lib/texthint/tooltip.cpp

https://invent.kde.org/utilities/kate/-/commit/9683da08798b327b8d41d80123a6773e9246821c
Comment 2 Adam Fontenot 2024-08-23 13:42:49 UTC
(In reply to Waqar Ahmed from comment #1)
> Git commit 9683da08798b327b8d41d80123a6773e9246821c by Waqar Ahmed.
> Committed on 23/08/2024 at 08:05.
> Pushed by waqar into branch 'master'.

This fixes most of the issue for me, thanks!

I'm still seeing problems in a few cases where a code block in the documentation causes scrolling in a case where a slightly larger box would solve the problem. E.g. hovering a `std::string::String` in Rust. The documentation has the following line - in a *code* block, which is significant:

// unsafe because we are responsible for making sure the components are

that's 72 characters wide, I think that's a reasonable amount of text to try to show in one line in a popup box. The popup box seems to be limited to about 40% of the text area width plus some (very small) minimum size, which seems just too small in a lot of cases.

In my opinion, soft wrapping text that extends too far would be preferable to adding a horizontal scroll bar. Horizontal scrollbars make text nearly impossible to read because you have to scroll back and forth on every affected line. (They also behave badly with a lot of touchpads because you don't have that much control over whether you drag left or right as you scroll up and down.)
Comment 3 Adam Fontenot 2024-08-23 13:49:33 UTC
Created attachment 172879 [details]
screenshot of issue with large window size

Here's a screenshot to show what I mean. I have a huge window, and the LSP box is refusing to use it, instead inserting a scrollbar to get 10 or so more pixels.

As an aside, it would be a nice feature addition to allow changing the size of the text in the popup box. I'd like to set it to 1px or 2px smaller than the text in my editor, which would also allow the box to have a bit more room.
Comment 4 Waqar Ahmed 2024-08-23 14:15:57 UTC
Lets stick to 1 issue per bug report.

Soft wrapping is nice, I agree, but it also makes some thing not easy e.g., for softwrapping to work there needs to be some width. And it makes calculating the final size of the tooltip a bit difficult. Its not impossible though, just no one has put in the effort yet.
Comment 5 Waqar Ahmed 2024-08-23 18:24:06 UTC
Git commit af5d2c83457fe4e788fc7d465f387fe90e707b76 by Waqar Ahmed.
Committed on 23/08/2024 at 18:21.
Pushed by waqar into branch 'release/24.08'.

Dont insert line breaks in tooltip
(cherry picked from commit 9683da08798b327b8d41d80123a6773e9246821c)

M  +0    -1    apps/lib/texthint/tooltip.cpp

https://invent.kde.org/utilities/kate/-/commit/af5d2c83457fe4e788fc7d465f387fe90e707b76