mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-19 02:17:35 +03:00
vim: Keep multi-cursor on escape (#8464)
Release Notes: - vim: Preserve multiple selections when returning to normal mode. /cc @mrnugget
This commit is contained in:
parent
f3fa3b910a
commit
8fc2431a2a
@ -2341,32 +2341,11 @@ impl Editor {
|
||||
}
|
||||
|
||||
pub fn cancel(&mut self, _: &Cancel, cx: &mut ViewContext<Self>) {
|
||||
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<Self>) -> 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<Self>) {
|
||||
let text: Arc<str> = text.into();
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user