Skip to content

Conversation

@SomeoneToIgnore
Copy link
Contributor

@SomeoneToIgnore SomeoneToIgnore commented Oct 14, 2025

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

  • Reworked inlay hints to be less error-prone

SomeoneToIgnore and others added 30 commits October 14, 2025 16:24
# 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]>

# 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
@SomeoneToIgnore SomeoneToIgnore marked this pull request as ready for review October 20, 2025 13:08
@SomeoneToIgnore SomeoneToIgnore merged commit ed5b9a4 into main Oct 22, 2025
22 checks passed
@SomeoneToIgnore SomeoneToIgnore deleted the kb/shared-inlays-2 branch October 22, 2025 19:34
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]>
SomeoneToIgnore added a commit that referenced this pull request Oct 24, 2025
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
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

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

2 participants