Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
vim: Prevent flickering during movement actions (#52270)
Finn Eitreime18da9ef6d80
diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rsindex 50e74a02bff..40d6a369692 100644--- a/crates/workspace/src/workspace.rs+++ b/crates/workspace/src/workspace.rs@@ -3364,24 +3364,27 @@ impl Workspace {};keystroke};- cx.update(|window, cx| {- let focused = window.focused(cx);- window.dispatch_keystroke(keystroke.clone(), cx);- if window.focused(cx) != focused {- // dispatch_keystroke may cause the focus to change.- // draw's side effect is to schedule the FocusChanged events in the current flush effect cycle- // And we need that to happen before the next keystroke to keep vim mode happy...- // (Note that the tests always do this implicitly, so you must manually test with something like:- // "bindings": { "g z": ["workspace::SendKeystrokes", ": j <enter> u"]}- // )- window.draw(cx).clear();- }- })- .ok();+ let focus_changed = cx+ .update(|window, cx| {+ let focused = window.focused(cx);+ window.dispatch_keystroke(keystroke.clone(), cx);+ if window.focused(cx) != focused {+ // dispatch_keystroke may cause the focus to change.+ // draw's side effect is to schedule the FocusChanged events in the current flush effect cycle+ // And we need that to happen before the next keystroke to keep vim mode happy...+ // (Note that the tests always do this implicitly, so you must manually test with something like:+ // "bindings": { "g z": ["workspace::SendKeystrokes", ": j <enter> u"]}+ // )+ window.draw(cx).clear();+ return true;+ }+ false+ })+ .unwrap_or(false);- // Yield between synthetic keystrokes so deferred focus and- // other effects can settle before dispatching the next key.- yield_now().await;+ if focus_changed {+ yield_now().await;+ }}*keystrokes.borrow_mut() = Default::default();