-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Rework inlay hints system #40183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Rework inlay hints system #40183
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Conflicts: # crates/project/src/lsp_store.rs # Conflicts: # crates/project/src/lsp_store.rs # Conflicts: # crates/editor/src/editor.rs # crates/project/src/lsp_store.rs # Conflicts: # crates/project/src/lsp_store.rs
# Conflicts: # crates/editor/src/editor.rs
# Conflicts: # crates/editor/src/editor.rs
Co-authored-by: Lukas Wirth <[email protected]> # Conflicts: # crates/editor/src/editor.rs
Co-authored-by: Lukas Wirth <[email protected]> # Conflicts: # crates/project/src/lsp_store.rs
Co-authored-by: Lukas Wirth <[email protected]>
Co-authored-by: Lukas Wirth <[email protected]>
Co-authored-by: Lukas Wirth <[email protected]> # Conflicts: # crates/editor/src/editor.rs # crates/editor/src/hover_links.rs # Conflicts: # crates/editor/src/hover_links.rs
# Conflicts: # crates/editor/src/inlays.rs
# Conflicts: # crates/editor/src/hover_links.rs
Inlay hints are shared and abundant, received from multiple servers, and can potentially overflow u32 during long sessions.
* from LSP response, if their position does not match the query range * from cache responses, if their kind does not match the editor's enabled ones
897f6f2 to
4f0c4f5
Compare
Closed
SomeoneToIgnore
added a commit
that referenced
this pull request
Oct 23, 2025
Before, inlay chunks were retrieved from the cache based on actualized anchor ranges, but using an old buffer snapshot. Now, update all chunks and snapshot to the actual before returning the applicable ones. Follow-up of #40183 Release Notes: - N/A
lidm0707
pushed a commit
to lidm0707/zed
that referenced
this pull request
Oct 23, 2025
Closes zed-industries#40047 Closes zed-industries#24798 Closes zed-industries#24788 Before, each editor, even if it's the same buffer split in 2, was querying for inlay hints separately, and storing the whole inlay hint twice, in `Editor`'s `display_map` and its `inlay_hint_cache` fields. Now, instead of `inlay_hint_cache`, each editor maintains a minimal set of metadata (which area was queried by what task) instead, and all LSP inlay hint data had been moved into `LspStore`, both local and remote flavors store the data. This allows Zed, as long as a buffer is open, to reuse the inlay hint data similar to how document colors and code lens are now stored and reused. Unlike other reused LSP data, inlay hints data is the first one that's possible to query by document ranges and previous version had issue with caching and invalidating such ranges already queried for. The new version re-approaches this by chunking the file into row ranges, which are queried based on the editors' visible area. Among the corresponding refactoring, one notable difference in inlays display are multi buffers: buffers in them are not [registered](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_didOpen) in the language server until a caret/selection is placed inside their excerpts inside the multi buffer. New inlays code does not query language servers for unregistered buffers, as servers usually respond with empty responses or errors in such cases. Release Notes: - Reworked inlay hints to be less error-prone --------- Co-authored-by: Lukas Wirth <[email protected]> Co-authored-by: dino <[email protected]> Co-authored-by: Lukas Wirth <[email protected]>
This was referenced Oct 23, 2025
Closed
SomeoneToIgnore
added a commit
that referenced
this pull request
Oct 28, 2025
Follow-up of #40183 Release Notes: - N/A --------- Co-authored-by: Lukas Wirth <[email protected]>
SomeoneToIgnore
added a commit
that referenced
this pull request
Nov 3, 2025
Follow-up of #40183 Release Notes: - (Preview only) Fixed inlay hints duplicating when multiple editors are open for the same buffer --------- Co-authored-by: Lukas Wirth <[email protected]>
SomeoneToIgnore
added a commit
that referenced
this pull request
Nov 3, 2025
Follow-up of #40183 Release Notes: - (Preview only) Fixed inlay hints duplicating when multiple editors are open for the same buffer --------- Co-authored-by: Lukas Wirth <[email protected]>
P1n3appl3
pushed a commit
to bnjjj/zed
that referenced
this pull request
Nov 4, 2025
Follow-up of zed-industries#40183 Release Notes: - (Preview only) Fixed inlay hints duplicating when multiple editors are open for the same buffer --------- Co-authored-by: Lukas Wirth <[email protected]>
tomatitito
pushed a commit
to tomatitito/zed
that referenced
this pull request
Nov 7, 2025
…41363) Follow-up of zed-industries#40183 Release Notes: - N/A --------- Co-authored-by: Lukas Wirth <[email protected]>
tomatitito
pushed a commit
to tomatitito/zed
that referenced
this pull request
Nov 7, 2025
Follow-up of zed-industries#40183 Release Notes: - (Preview only) Fixed inlay hints duplicating when multiple editors are open for the same buffer --------- Co-authored-by: Lukas Wirth <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #40047
Closes #24798
Closes #24788
Before, each editor, even if it's the same buffer split in 2, was querying for inlay hints separately, and storing the whole inlay hint twice, in
Editor'sdisplay_mapand itsinlay_hint_cachefields.Now, instead of
inlay_hint_cache, each editor maintains a minimal set of metadata (which area was queried by what task) instead, and all LSP inlay hint data had been moved intoLspStore, both local and remote flavors store the data.This allows Zed, as long as a buffer is open, to reuse the inlay hint data similar to how document colors and code lens are now stored and reused.
Unlike other reused LSP data, inlay hints data is the first one that's possible to query by document ranges and previous version had issue with caching and invalidating such ranges already queried for.
The new version re-approaches this by chunking the file into row ranges, which are queried based on the editors' visible area.
Among the corresponding refactoring, one notable difference in inlays display are multi buffers: buffers in them are not registered in the language server until a caret/selection is placed inside their excerpts, or those are not scrolled into visible area inside the multi buffer.
New inlays code does not query language servers for unregistered buffers, as servers usually respond with empty responses or errors in such cases.
Release Notes: