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.
This commit is contained in:
Thorsten Ball 2025-01-15 13:44:56 +01:00 committed by GitHub
parent bd3f64c5a1
commit bf75b33464
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View file

@ -1732,8 +1732,12 @@ impl Editor {
self.input_enabled = input_enabled; 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>) {
self.enable_inline_completions = enabled; 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) { pub fn set_autoindent(&mut self, autoindent: bool) {
@ -4785,6 +4789,7 @@ impl Editor {
|| (!self.completion_tasks.is_empty() && !self.has_active_inline_completion())); || (!self.completion_tasks.is_empty() && !self.has_active_inline_completion()));
if completions_menu_has_precedence if completions_menu_has_precedence
|| !offset_selection.is_empty() || !offset_selection.is_empty()
|| !self.enable_inline_completions
|| self || self
.active_inline_completion .active_inline_completion
.as_ref() .as_ref()

View file

@ -1240,7 +1240,7 @@ impl Vim {
.map_or(false, |provider| provider.show_completions_in_normal_mode()), .map_or(false, |provider| provider.show_completions_in_normal_mode()),
_ => false, _ => false,
}; };
editor.set_inline_completions_enabled(enable_inline_completions); editor.set_inline_completions_enabled(enable_inline_completions, cx);
}); });
cx.notify() cx.notify()
} }