Always wait for completion resolve before applying the completion edits (#18907)

After https://github.com/rust-lang/rust-analyzer/pull/18167 and certain
people who type and complete rapidly, it turned out that we have not
waited for `completionItem/resolve` to finish before applying the
completion results.

Release Notes:

- Fixed completion items applied improperly on fast typing
This commit is contained in:
Kirill Bulatov 2024-10-09 17:18:20 +03:00 committed by GitHub
parent f50bca7630
commit a62a2fa8f7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 144 additions and 63 deletions

View file

@ -363,10 +363,12 @@ mod tests {
// Confirming a completion inserts it and hides the context menu, without showing
// the copilot suggestion afterwards.
editor
.confirm_completion(&Default::default(), cx)
.unwrap()
.detach();
editor.confirm_completion(&Default::default(), cx).unwrap()
})
.await
.unwrap();
cx.update_editor(|editor, cx| {
assert!(!editor.context_menu_visible());
assert!(!editor.has_active_inline_completion(cx));
assert_eq!(editor.text(cx), "one.completion_a\ntwo\nthree\n");