editor: Show hover popover at the cursor position instead of the start of the range#49257
editor: Show hover popover at the cursor position instead of the start of the range#49257Ahmad-Alsaleh wants to merge 6 commits intozed-industries:mainfrom
Conversation
|
We require contributors to sign our Contributor License Agreement, and we don't have @Ahmad-Alsaleh on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
|
Thank you for the submission, but I do not think showing different popovers even more differently is the right way to fix the issue. #47471 (comment) describes a more viable (IMO) approach. |
|
I see. I only have two concerns about #47471 (comment). One, IMO, showing the popover near the line of hover, instead of the first line, is closer to what the user would expect. If a user hovers at line 10, their eyes are most likely staring at line 10. However, hovering at line 10 then moving my eyes multiple lines up (or even worse, needing to scroll up) just to see the error message might not, IMO, be the best UX. Let me know your thoughts, @SomeoneToIgnore, I might be missing something. Two, how would we address: #47471 (comment) and #47471 (comment)? That being said, if you are concerned that showing different popovers differently is not viable, we can keep all popover right-aligned (the original behavior). My point is to keep the popover near the line of hover instead of the start of the range for multiline diagnostics. |
|
I would propose not to mix things together, to increase the chances those are understood and merged.
Seems reasonable, but please be mindful there could be situations like
where multiple various popovers may be displayed at once (there could be more than the screenshot shows: at least there are assistant predictions and signature help popovers that are not shown here) This on its own is not a simple task to deal with, and maybe better to be improved one step at a time.
I may not understand that in the context of the issue: the popovers get too far away from the caret and get hidden. Given that the 2nd point "echoes" the first, and the first mentions that large popovers cover the entire screen, it's not 100% related to the issue? Overall, as you can see, I can mostly handwave and show which path we do consider right and which ones we do not. The contribution itself is not writing the code, LLMs can do that already, but to understand what to do, so I highly hope I am not forced to guide every step here: there are other editors which support hover popovers: VSCode, Intellij IDEs, etc. etc. — checking what they do in a similar situation is a so much better step forward compared to questioning the same questions for the 2nd time within a week. |

Closes #46841
When hovering over a multiline diagnostic (eg, a warning or an error), the popover is currently shown at the start of the diagnostic range (i.e., the first line). This can be problematic when the diagnostic spans multiple lines and the user is hovering near the bottom lines.
Users typically expect the popover to appear near their cursor position, not several lines above it. Additionally, if the cursor moves into surrounding whitespace, the popover disappears, as shown in the original issue #46841 by @injust (credit: the video below is taken from that issue)
535924927-310e0dbf-6282-4f7b-bcf9-8ca7486c7baa.mp4
The PR #47471 by @daydalek proposed keeping the diagnostic hover visible as long as the mouse row intersects with the active diagnostic's range, as shown below (credit: the video below is taken from that PR)
539756423-0965cb25-6207-4d4a-9165-0d51157fc6e4.mov
However, as previously mentioned, users typically expect the popover to appear near their cursor position. Also, @xdBronch noticed that...
This PR proposes fixing the aforementioned issues by positioning the popover near the cursor instead of the start of the diagnostic range, similar to user expectations and the behavior of other editors, such as VS Code.
In the videos below, note that the popovers do not exceed the window boundaries.
Hovering with the mouse
Recording.mov
Hovering with the keyboard in Vim mode (Shift+K)
Recording-2.mov
Checklist
Before you mark this PR as ready for review, make sure that you have:
Release Notes:
AI Assistance Disclosure
The tests in this PR were generated using AI, then reviewed and enhanced by me.
The implementation and overall changes were written by me with the assistance of AI.
This PR description is written by me and peer-reviewed by AI.