Skip to content

fix: cancel stale completion requests - #3263

Open
atirna wants to merge 1 commit into
zigtools:masterfrom
atirna:fix/completion-cimport-latency
Open

fix: cancel stale completion requests#3263
atirna wants to merge 1 commit into
zigtools:masterfrom
atirna:fix/completion-cimport-latency

Conversation

@atirna

@atirna atirna commented Sep 6, 2026

Copy link
Copy Markdown

Description

I cancel outstanding completion requests when a document-changing notification arrives. Completion declaration loops now check for cancellation, so stale requests release before the document refreshes.

Fixes #3251

Why

Large generated C bindings can make completion enumeration expensive. The response should reflect the latest document instead of waiting for earlier edits to finish.

Verification

  • before, on current master: a 30,000-declaration import with eight rapid textDocument/didChange and completion pairs left the newest response pending for 19.523 seconds
  • after: the same session returned the newest response in 0.694 seconds
  • zig build test -Dtest-filter=completion
  • zig build test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ZLS takes 20 seconds to perform code completion on c imports when you write the code yourself quickly

1 participant