rust-analyzer icon indicating copy to clipboard operation
rust-analyzer copied to clipboard

Reorder error/warning message and hover information when hovering with mouse in VSC

Open diliop opened this issue 5 years ago • 12 comments

Currently when hovering over parts of the code that have problems (errors, warnings etc.) associated with them, one needs to scroll down past the hover information to get to the error. Most of the times, the rendered hover information is longer than the maximum lines visible in one page of the hover pane forcing the error or warning message to not be visible without scrolling. This is a tad inconvenient and I find myself mostly using peek or the Problems view to see what the error messages are versus hovering with the mouse cursor and getting to see errors that way.

As an example, when hovering over the following error under the .format method, this is what comes up first: Screen Shot 2020-09-23 at 5 52 06 PM instead of the error which is placed in the last of the scrollable pages of the hover pane: Screen Shot 2020-09-23 at 5 52 23 PM

I have looked through the documentation and configuration parameters for rust-analyzer in VSC and I don't see a place where I can configure this behavior by making the error or warning come up first in the hover pane.

diliop avatar Sep 24 '20 01:09 diliop

I have the same issue, everytime I need to scroll down to see the error. I will check to change this behavior when we have an error or warning, put this message first. Any concerns about this @matklad ?

bnjjj avatar Sep 28 '20 08:09 bnjjj

Seems reasonable to me!

matklad avatar Sep 28 '20 10:09 matklad

Hmm after investing the issue it seems we have here the display of hover which is the function documentation and the signature and the display of diagnostics coming from textDocument/codeAction. I didn't find the way to change the display order between hover and textDocument/codeAction so vscode didn't let us configure this order. Maybe I'm wrong but I didn't find any information about this topic.

bnjjj avatar Sep 29 '20 21:09 bnjjj

Is there an upstream issue on VSCode to allow this to be fixed? Can this be worked around temporarily by hiding docs whenever an error would also be displayed?

obsgolem avatar Jan 04 '21 19:01 obsgolem

@obsgolem this one probably: Sort Hover Event (#71848)

Possible fix as per this comment by jrieken:

Providers get sorted by their score and in case of equal scores by registration time, later is better.

regexident avatar Feb 02 '21 08:02 regexident

Looking into this I don't think that would work. The score algorithm is based on the strength of the file's match. Rust-Analyzer should get 10, the max, on every .rs file

obsgolem avatar Feb 10 '21 03:02 obsgolem

Upstream issue: https://github.com/microsoft/vscode/issues/73120

edwin0cheng avatar Mar 26 '21 03:03 edwin0cheng

Diagnostics are now showing up on top for me, did we deliberately fix this?

jonas-schievink avatar Aug 29 '21 14:08 jonas-schievink

I don't think we did

Veykril avatar Aug 29 '21 15:08 Veykril

As a headsup, this has been un-fixed again somehow, diagnostics are now appearing below docs again...

Veykril avatar Jan 07 '22 18:01 Veykril

@Veykril Microsoft or in particular @sandy081 don't seem to prioritize this issue. Would it be possible to detect that a hover has both general information like documentation and an error. And to tell VS Code that it doesn't have any documentation, so that it surfaces the issue directly?

mvtec-bergdolll avatar Sep 08 '22 14:09 mvtec-bergdolll

That is a hack I don't see us wanting to have. Sometimes you do want the docs on code with erroneous lines if you are in the middle of writing something which would be a massive annoyance as well. I'd rather Microsoft would just finally fix these importing UX bugs (but you are right, I don't see them going to do that in the near future either ...).

There seems to be a possible fix up https://github.com/microsoft/vscode/pull/166560

Veykril avatar Sep 08 '22 15:09 Veykril

VSCode just merged https://github.com/microsoft/vscode/pull/166560 so this should be fixed in an upcoming release

Veykril avatar Feb 27 '23 20:02 Veykril