Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

vim: Keep multi-cursor on escape (#8464)

Conrad Irwin8fc2431a2ac1
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index f32273b6e37..6fb25c54262 100644
--- a/crates/editor/src/editor.rs
+++ b/crates/editor/src/editor.rs
@@ -2341,38 +2341,48 @@ impl Editor {
}
pub fn cancel(&mut self, _: &Cancel, cx: &mut ViewContext<Self>) {
- if self.take_rename(false, cx).is_some() {
+ if self.dismiss_menus_and_popups(cx) {
return;
}
+ if self.mode == EditorMode::Full {
+ if self.change_selections(Some(Autoscroll::fit()), cx, |s| s.try_cancel()) {
+ return;
+ }
+ }
+
+ cx.propagate();
+ }
+
+ pub fn dismiss_menus_and_popups(&mut self, cx: &mut ViewContext<Self>) -> bool {
+ if self.take_rename(false, cx).is_some() {
+ return true;
+ }
+
if hide_hover(self, cx) {
- return;
+ return true;
}
if self.hide_context_menu(cx).is_some() {
- return;
+ return true;
}
if self.discard_copilot_suggestion(cx) {
- return;
+ return true;
}
if self.snippet_stack.pop().is_some() {
- return;
+ return true;
}
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;
+ return true;
}
}
- cx.propagate();
+ false
}
pub fn handle_input(&mut self, text: &str, cx: &mut ViewContext<Self>) {
diff --git a/crates/vim/src/insert.rs b/crates/vim/src/insert.rs
index 6ac3f28695b..064c4b67a03 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);