Bug 475252 - LSP tooltip doesn't display correctly sometimes
Summary: LSP tooltip doesn't display correctly sometimes
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: application (other bugs)
Version First Reported In: 23.08.0
Platform: Other Other
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-10-05 16:34 UTC by Hugues Morisset
Modified: 2023-10-10 06:53 UTC (History)
2 users (show)

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


Attachments
Working and non working tooltip (110.84 KB, image/png)
2023-10-05 16:34 UTC, Hugues Morisset
Details
rustin (5.94 KB, text/plain)
2023-10-06 14:48 UTC, Hugues Morisset
Details
rustout (23.13 KB, text/plain)
2023-10-06 14:49 UTC, Hugues Morisset
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hugues Morisset 2023-10-05 16:34:08 UTC
Created attachment 162102 [details]
Working and non working tooltip

SUMMARY
When using kate with rust LSP, I sometime get miss displayed tooltips when hovering on variables or types,
It looks like html is leaking as plain text (see screenshot).
It seem to mainly occur when the corresponding rust code doesn't not compile.

STEPS TO REPRODUCE
1.  Write non compiling rust code
2. Turn on rust LSP

OBSERVED RESULT
Error tooltip shows HTML markers

EXPECTED RESULT
Error tooltip should display correctly

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Kde neon
KDE Plasma Version: 5.27.7
KDE Frameworks Version: 5.110.0
Qt Version: 5.15.10

ADDITIONAL INFORMATION
Comment 1 Waqar Ahmed 2023-10-05 16:48:18 UTC
Would help if you provide example rust code
Comment 2 Hugues Morisset 2023-10-06 10:10:08 UTC
Sorry, here a simple example

```
async fn main() -> Result<(), dyn std::error::Error> {
    std::thread::sleep(std::time::Duration::from_secs(2))
}
```

I get 
```
[rustc] (E0308) mismatched types
expected enum Result&lt;(), (dyn std::error::Error + 'static)&gt;
found unit type ()
[main.rs:1] expected Result&lt;(), (dyn std::error::Error + 'static)&gt; because of return type
[main.rs:2] try adding an expression at the end of the block: ;   Ok(())
```

I tried removing the async keyword, and the tooltip displays correctly then.
```
[rust-analyzer] (E0308) expected Result<(), dyn Error>, found ()
```
Comment 3 Waqar Ahmed 2023-10-06 12:23:59 UTC
I have tried multiple times but I can't see a broken tooltip. I only see the following tooltip and a different one which shows the description of symbol under cursor along with the error below

```
[rust-analyzer] (E0308) expected Result<(), dyn Error>, found ()
```

---

My rust analyzer version is:
```
rust-analyzer --version
rust-analyzer 1.71.0 (8ede3aa 2023-07-12)
```
Comment 4 Waqar Ahmed 2023-10-06 12:24:46 UTC
Sorry this is the tooltip I see:
```
[rust-analyzer] (type-mismatch) expected Result<(), dyn Error>, found ()
```
Comment 5 Hugues Morisset 2023-10-06 14:48:44 UTC
Created attachment 162124 [details]
rustin
Comment 6 Hugues Morisset 2023-10-06 14:49:00 UTC
Created attachment 162125 [details]
rustout
Comment 7 Hugues Morisset 2023-10-06 14:49:08 UTC
Maybe something to do with locales?
```
$ rust-analyzer --version && kate --version && env | grep 'LC_*'
rust-analyzer 1.74.0-nightly (65ea825 2023-09-18)
QSocketNotifier: Can only be used with threads started with QThread
kate 23.08.1
LC_ADDRESS=fr_FR.UTF-8
LC_NAME=fr_FR.UTF-8
LC_MONETARY=fr_FR.UTF-8
LC_PAPER=fr_FR.UTF-8
LC_IDENTIFICATION=en_US.UTF-8
LC_RESPONSE=POSIX
LC_TELEPHONE=fr_FR.UTF-8
LC_MESSAGES=POSIX
LC_MEASUREMENT=fr_FR.UTF-8
LC_CTYPE=en_US.UTF-8
LC_TIME=fr_FR.UTF-8
LC_COLLATE=en_US.UTF-8
LC_NUMERIC=fr_FR.UTF-8
```

I changed LSP to be script that does the following
```
tee /tmp/lsp/rustin | rustup run nightly rust-analyzer "$@" | tee /tmp/lsp/rustout
```
loaded the file containing the example code and displayed the tooltip (which displayed incorrectly).
rustin and rustout are provided in attachments
Comment 8 Waqar Ahmed 2023-10-06 17:11:17 UTC
Reproduced after upgrading rust-analyzer
Comment 9 Waqar Ahmed 2023-10-10 06:53:47 UTC
Git commit b20feef77ca830684ce8570e59e63830791c28a5 by Waqar Ahmed.
Committed on 10/10/2023 at 08:51.
Pushed by waqar into branch 'master'.

Use plainText for diagnostic tooltip

M  +2    -2    apps/lib/diagnostics/diagnosticview.cpp

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