Reorder error/warning message and hover information when hovering with mouse in VSC
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:
instead of the error which is placed in the last of the scrollable pages of the hover pane:

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.
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 ?
Seems reasonable to me!
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.
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 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.
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
Upstream issue: https://github.com/microsoft/vscode/issues/73120
Diagnostics are now showing up on top for me, did we deliberately fix this?
I don't think we did
As a headsup, this has been un-fixed again somehow, diagnostics are now appearing below docs again...
@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?
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
VSCode just merged https://github.com/microsoft/vscode/pull/166560 so this should be fixed in an upcoming release