From 78b36a466b1b8881575b76524314e7118c4563b2 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Mon, 9 Dec 2024 19:10:34 +0100 Subject: [PATCH] lsp: Disable usage of follow-up completion invokes (#21755) Some of our users ran into a peculiar bug: autoimports with vtsls were leaving behind an extra curly brace. I think we were slightly incorrect in always requesting a follow-up completion without regard for last result of completion request (whether it was incomplete or not). Specifically, we're falling into this branch in current form: https://github.com/yioneko/vtsls/blob/037c2b615bf4cfe9dd65d9affc7a155fbb2ca255/packages/service/src/service/completion.ts#L121 which then leads to incorrect edits being returned from vtsls. Release Notes: - Fixed an edge case with appliance of autocompletions in VTSLS that could result in incorrect edits being applied. --- crates/editor/src/editor.rs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 137cf379cd71b3fe71ecedcdf330b7bba3d73290..613a231d7d1b8a2f8262e88333995b70ed4680e4 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -4452,19 +4452,10 @@ impl Editor { }; let query = Self::completion_query(&self.buffer.read(cx).read(cx), position); - let is_followup_invoke = { - let context_menu_state = self.context_menu.read(); - matches!( - context_menu_state.deref(), - Some(ContextMenu::Completions(_)) - ) - }; - let trigger_kind = match (&options.trigger, is_followup_invoke) { - (_, true) => CompletionTriggerKind::TRIGGER_FOR_INCOMPLETE_COMPLETIONS, - (Some(trigger), _) if buffer.read(cx).completion_triggers().contains(trigger) => { + let trigger_kind = match &options.trigger { + Some(trigger) if buffer.read(cx).completion_triggers().contains(trigger) => { CompletionTriggerKind::TRIGGER_CHARACTER } - _ => CompletionTriggerKind::INVOKED, }; let completion_context = CompletionContext {