From 7fafc88706004757b5e6dff30211667f2f286ad9 Mon Sep 17 00:00:00 2001 From: Thorsten Ball Date: Wed, 15 Jan 2025 13:44:56 +0100 Subject: [PATCH] vim: Fix inline completions not disappearing in normal mode (#23176) Closes #23042 Release Notes: - Fixed inline completions (Copilot, Supermaven, ...) still being visible sometimes after leaving Vim's insert mode. --- crates/editor/src/editor.rs | 7 ++++++- crates/vim/src/vim.rs | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 0179710f71528c063c07f1e18e1625573c696941..afc273b39b969b907169f939d3e41f1d34cfef72 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -1727,8 +1727,12 @@ impl Editor { self.input_enabled = input_enabled; } - pub fn set_inline_completions_enabled(&mut self, enabled: bool) { + pub fn set_inline_completions_enabled(&mut self, enabled: bool, cx: &mut ViewContext) { self.enable_inline_completions = enabled; + if !self.enable_inline_completions { + self.take_active_inline_completion(cx); + cx.notify(); + } } pub fn set_autoindent(&mut self, autoindent: bool) { @@ -4777,6 +4781,7 @@ impl Editor { || (!self.completion_tasks.is_empty() && !self.has_active_inline_completion())); if completions_menu_has_precedence || !offset_selection.is_empty() + || !self.enable_inline_completions || self .active_inline_completion .as_ref() diff --git a/crates/vim/src/vim.rs b/crates/vim/src/vim.rs index 5e64d1c93ec002cb9366dd3515c10f782a64ce48..2e5f0aae6f01650404cef7ff9de96ac1223eb811 100644 --- a/crates/vim/src/vim.rs +++ b/crates/vim/src/vim.rs @@ -1204,7 +1204,7 @@ impl Vim { .map_or(false, |provider| provider.show_completions_in_normal_mode()), _ => false, }; - editor.set_inline_completions_enabled(enable_inline_completions); + editor.set_inline_completions_enabled(enable_inline_completions, cx); }); cx.notify() }