Repository navigation
fix(editor): send the pending text before asking for completions - #805
Merged
Merged
Conversation
The editor sends its text to the language server 150 ms after the last keystroke, but CodeMirror asks for completions as soon as typing pauses for 100 ms. Typed without a pause, `@sal` was completed against the text from before the `@`, and the list stayed empty; only typing slower than the debounce got suggestions. The completion request now sends the waiting change first. The socket keeps the order, so the server reads the current text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MmrM91dHzvQoaerCcR9wra
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
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 #804
The editor's completion request now sends the text still waiting for the 150 ms
didChangedebounce first, so the language server completes the text as it is.flushLspChange(). The debounce timer calls it as before, and the completion resolver calls it right beforetextDocument/completion. It sends nothing when no change is pending. The WebSocket keeps message order, sodidChangearrives first.CooklangEditor.getContent), which is what the timer would have sent at the end of the debounce anyway.Tests
editor-completion-typing.spec.tstypes@salwithout a pause in a recipe that uses@salt{}and expectssaltto be offered. Run 5 times (--repeat-each=5): 5/5 pass with the fix, 5/5 fail without theflushLspChange()call.edit.htmland merge cleanly.cargo test --workspace: 1865 passed. Full chromium Playwright run green, apart from the specs that spawntarget/debug/cook, which doesn't exist in my local setup. The pantry and shopping-list specs were rerun with--workers=1, as on CI.🤖 Generated with Claude Code
https://claude.ai/code/session_01MmrM91dHzvQoaerCcR9wra