Skip to content

editor: Fix a bunch of inlay hint bugs#50377

Merged
Veykril merged 5 commits intomainfrom
push-pzxoprrmvmrt
Feb 28, 2026
Merged

editor: Fix a bunch of inlay hint bugs#50377
Veykril merged 5 commits intomainfrom
push-pzxoprrmvmrt

Conversation

@Veykril
Copy link
Copy Markdown
Member

@Veykril Veykril commented Feb 28, 2026

Release Notes:

  • Fixed multiple language servers applying to the same buffer overwriting each others inlay hints
  • Fixed multiple language servers applying to the same multibuffer discarding each others inlay hints
  • Fixed a bug that caused some inlay hints to sometimes duplicate

When BufferEdited fires, refresh_inlay_hints filters visible_excerpts to
only same-language buffers but calls clear() globally, wiping added_hints
and hint_chunk_fetching for all buffers including other languages. Those
other-language hints remain displayed but their tracking state is gone, so
the next NewLinesShown re-fetches and inserts them alongside the
still-displayed copies, producing duplicates.

Replace the global clear() with a targeted clear_for_buffers() that only
wipes tracking for the buffers actually being re-processed. Other-language
buffers keep their tracking intact, preventing re-fetch and duplication.
When a BufferEdited task completes with should_invalidate()=true, apply_fetched_hints
removes ALL visible hints for the buffer but only adds back hints for the chunks this
task fetched. Chunks fetched by other concurrent tasks (e.g., a scroll task that
completed during the edit debounce) have their hints removed but remain marked as
"already fetched" in hint_chunk_fetching, permanently preventing re-fetch.

Fix: when invalidating, prune hint_chunk_fetching to retain only the chunk ranges that
this task has results for, so orphaned chunks become eligible for re-fetch on the next
NewLinesShown event.
Two bugs caused inlay hints to permanently disappear until the next edit:

Bug 1 — Race between invalidating and appending tasks:
When a buffer edit (long debounce) was followed by a scroll (short debounce),
the edit task's apply_fetched_hints removed ALL visible hints but only added
back its own chunks. The scroll chunk remained in hint_chunk_fetching as
"already fetched", preventing re-query. Fixed by pruning hint_chunk_fetching
to only retain chunks this task has results for when should_invalidate() is
true.

Bug 2 — RefreshRequested dropping other servers' hints:
When one LSP server sent workspace/inlayHint/refresh, clear() wiped all
tracking, then the LspStore only returned the requesting server's hints
(other servers' cached hints were excluded). apply_fetched_hints removed all
visible hints but only added back the one server's. Fixed by capturing other
servers' cached hints before spawning the fetch task and merging them into
the result.
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Feb 28, 2026
@zed-community-bot zed-community-bot bot added the staff Pull requests authored by a current member of Zed staff label Feb 28, 2026
@Veykril Veykril enabled auto-merge (squash) February 28, 2026 09:28
@Veykril Veykril disabled auto-merge February 28, 2026 09:28
@Veykril Veykril enabled auto-merge (squash) February 28, 2026 09:36
@Veykril Veykril merged commit 5a40e68 into main Feb 28, 2026
28 checks passed
@Veykril Veykril deleted the push-pzxoprrmvmrt branch February 28, 2026 09:44
tahayvr pushed a commit to tahayvr/zed that referenced this pull request Mar 4, 2026
Release Notes:

- Fixed multiple language servers applying to the same buffer
overwriting each others inlay hints
- Fixed multiple language servers applying to the same multibuffer
discarding each others inlay hints
- Fixed a bug that caused some inlay hints to sometimes duplicate
naaiyy pushed a commit to Glass-HQ/Glass that referenced this pull request Mar 11, 2026
Release Notes:

- Fixed multiple language servers applying to the same buffer
overwriting each others inlay hints
- Fixed multiple language servers applying to the same multibuffer
discarding each others inlay hints
- Fixed a bug that caused some inlay hints to sometimes duplicate
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 staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant