Skip to content

fix(completion): rebase refreshed edits from their request - #313

Merged
fcoury-oai merged 1 commit into
mainfrom
fcoury/completion-snapshot-rebase
Aug 22, 2026
Merged

fcoury-oai merged 1 commit into
mainfrom
fcoury/completion-snapshot-rebase

Conversation

@fcoury-oai

Copy link
Copy Markdown
Collaborator

Why

Accepting a refreshed completion can close the popup without changing the buffer. Red reuses the popup's original snapshot for newer buffer-word and language-server candidates, even though their edits already target the newer document revision. The edit is rebased twice and rejected with an error such as LSP position 319:25 is outside its line. Older completion responses can also arrive after newer requests and replace current candidates.

What changed

  • Create a fresh replacement-range snapshot for every completion request and use it for both immediately displayed buffer candidates and the corresponding LSP response.
  • Rebase refreshed completion edits only for text entered after their own request.
  • Supersede older in-flight completion requests for the same document so late responses cannot replace newer results.
  • Add regressions for refreshed buffer-word completions, refreshed LSP completions with continued typing, and superseded out-of-order responses.

How to Test

  1. Open a Rust file with an available member such as self.app_event_tx, insert a new line, and type self.app while the completion popup refreshes. Select app_event_tx and press Enter; the member should replace app without an outside its line error.
  2. Repeat while typing more characters after the refreshed menu appears, or request completion twice quickly. The selected completion should still apply, and an older response must not replace the newer candidates.
  3. Run cargo test --lib refreshed_; all three targeted stale-snapshot and out-of-order regressions should pass.
  4. Run cargo test --lib completion and cargo test --test completion; the 144 completion-related unit tests and 46 integration tests should pass.
  5. Run cargo clippy --all-targets --all-features -- -D warnings; it should finish without warnings.

@fcoury-oai
fcoury-oai merged commit 100ae37 into main Aug 22, 2026
10 checks passed
@fcoury-oai
fcoury-oai deleted the fcoury/completion-snapshot-rebase branch August 22, 2026 20:40
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.

1 participant