Skip to content

editor: Show hover popover at the cursor position instead of the start of the range#49257

Closed
Ahmad-Alsaleh wants to merge 6 commits intozed-industries:mainfrom
Ahmad-Alsaleh:alsaleh
Closed

editor: Show hover popover at the cursor position instead of the start of the range#49257
Ahmad-Alsaleh wants to merge 6 commits intozed-industries:mainfrom
Ahmad-Alsaleh:alsaleh

Conversation

@Ahmad-Alsaleh
Copy link
Copy Markdown

@Ahmad-Alsaleh Ahmad-Alsaleh commented Feb 16, 2026

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...

a possible problem with this [fix] is how it interacts with inactive regions in clangd which are implemented using diagnostics. since its between #ifdefs the diagnostic can often be hundreds or even thousands of lines which means the hover will basically never go away since the whole screen is a diagnostic

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:

  • Added a solid test coverage and/or screenshots from doing manual testing
  • Done a self-review taking into account security and performance aspects
  • Aligned any UI changes with the UI checklist

Release Notes:

  • The diagnostic hover popover is now shown at the cursor position instead of the start of the diagnostic range.
  • Diagnostic hover popovers are aligned to the left of the cursor.
  • Other hover popovers (e.g., LSP hints and type definitions) remain aligned to the right of the cursor.

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.

@cla-bot
Copy link
Copy Markdown

cla-bot bot commented Feb 16, 2026

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'.

@zed-community-bot zed-community-bot bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Feb 16, 2026
@Ahmad-Alsaleh
Copy link
Copy Markdown
Author

@cla-bot check

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Feb 16, 2026
@cla-bot
Copy link
Copy Markdown

cla-bot bot commented Feb 16, 2026

The cla-bot has been summoned, and re-checked this pull request!

@Ahmad-Alsaleh Ahmad-Alsaleh changed the title Alsaleh editor: Show hover popover at the cursor position instead of the start of the range Feb 16, 2026
@SomeoneToIgnore
Copy link
Copy Markdown
Contributor

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.

@Ahmad-Alsaleh
Copy link
Copy Markdown
Author

Ahmad-Alsaleh commented Feb 16, 2026

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.

@SomeoneToIgnore
Copy link
Copy Markdown
Contributor

SomeoneToIgnore commented Feb 16, 2026

I would propose not to mix things together, to increase the chances those are understood and merged.

One

Seems reasonable, but please be mindful there could be situations like

image

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 am not 100% certain that the hover popover has to always appear just to the right of the caret, as completions are much more important and it would be so much more confusing to push them away somewhere.

Two

I may not understand that in the context of the issue: the popovers get too far away from the caret and get hidden.
By introducing the timeout, we're supposed to allow the cursor to hover the popovers without them disappearing.

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?
We have ESC to hide these.


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.

@Ahmad-Alsaleh Ahmad-Alsaleh deleted the alsaleh branch February 16, 2026 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Diagnostic hover popover disappears when moving mouse cursor to the popover

2 participants