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.

Fix renaming sometimes not working in vim mode (#14320)

Congyu64a796d436ee
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index e62369164cb..6c6035d4e1e 100644
--- a/crates/editor/src/editor.rs
+++ b/crates/editor/src/editor.rs
@@ -1770,6 +1770,8 @@ impl Editor {
);
let focus_handle = cx.focus_handle();
cx.on_focus(&focus_handle, Self::handle_focus).detach();
+ cx.on_focus_in(&focus_handle, Self::handle_focus_in)
+ .detach();
cx.on_focus_out(&focus_handle, Self::handle_focus_out)
.detach();
cx.on_blur(&focus_handle, Self::handle_blur).detach();
@@ -11632,6 +11634,10 @@ impl Editor {
}
}
+ fn handle_focus_in(&mut self, cx: &mut ViewContext<Self>) {
+ cx.emit(EditorEvent::FocusedIn)
+ }
+
fn handle_focus_out(&mut self, event: FocusOutEvent, _cx: &mut ViewContext<Self>) {
if event.blurred != self.focus_handle {
self.last_focused_descendant = Some(event.blurred);
@@ -12236,6 +12242,7 @@ pub enum EditorEvent {
},
Reparsed(BufferId),
Focused,
+ FocusedIn,
Blurred,
DirtyChanged,
Saved,
diff --git a/crates/vim/src/vim.rs b/crates/vim/src/vim.rs
index cf800f854fd..43915d796dc 100644
--- a/crates/vim/src/vim.rs
+++ b/crates/vim/src/vim.rs
@@ -268,6 +268,7 @@ impl Vim {
EditorEvent::Edited { .. } => {
Vim::update(cx, |vim, cx| vim.transaction_ended(editor, cx))
}
+ EditorEvent::FocusedIn => Vim::update(cx, |vim, cx| vim.sync_vim_settings(cx)),
_ => {}
}));