diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index f32273b6e3..6fb25c5426 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -2341,32 +2341,11 @@ impl Editor { } pub fn cancel(&mut self, _: &Cancel, cx: &mut ViewContext) { - if self.take_rename(false, cx).is_some() { - return; - } - - if hide_hover(self, cx) { - return; - } - - if self.hide_context_menu(cx).is_some() { - return; - } - - if self.discard_copilot_suggestion(cx) { - return; - } - - if self.snippet_stack.pop().is_some() { + if self.dismiss_menus_and_popups(cx) { return; } if self.mode == EditorMode::Full { - if self.active_diagnostics.is_some() { - self.dismiss_diagnostics(cx); - return; - } - if self.change_selections(Some(Autoscroll::fit()), cx, |s| s.try_cancel()) { return; } @@ -2375,6 +2354,37 @@ impl Editor { cx.propagate(); } + pub fn dismiss_menus_and_popups(&mut self, cx: &mut ViewContext) -> bool { + if self.take_rename(false, cx).is_some() { + return true; + } + + if hide_hover(self, cx) { + return true; + } + + if self.hide_context_menu(cx).is_some() { + return true; + } + + if self.discard_copilot_suggestion(cx) { + return true; + } + + if self.snippet_stack.pop().is_some() { + return true; + } + + if self.mode == EditorMode::Full { + if self.active_diagnostics.is_some() { + self.dismiss_diagnostics(cx); + return true; + } + } + + false + } + pub fn handle_input(&mut self, text: &str, cx: &mut ViewContext) { let text: Arc = text.into(); diff --git a/crates/vim/src/insert.rs b/crates/vim/src/insert.rs index 6ac3f28695..064c4b67a0 100644 --- a/crates/vim/src/insert.rs +++ b/crates/vim/src/insert.rs @@ -16,7 +16,7 @@ fn normal_before(_: &mut Workspace, action: &NormalBefore, cx: &mut ViewContext< vim.stop_recording_immediately(action.boxed_clone()); if count <= 1 || vim.workspace_state.replaying { vim.update_active_editor(cx, |_, editor, cx| { - editor.cancel(&Default::default(), cx); + editor.dismiss_menus_and_popups(cx); editor.change_selections(Some(Autoscroll::fit()), cx, |s| { s.move_cursors_with(|map, mut cursor, _| { *cursor.column_mut() = cursor.column().saturating_sub(1);