diff --git a/crates/command_palette/src/command_palette.rs b/crates/command_palette/src/command_palette.rs index a6fc0193a4b18407c2f4473a0fbea471d91eb9a9..d13360a7c5403d997cfb2363f33cfe3b257dcef1 100644 --- a/crates/command_palette/src/command_palette.rs +++ b/crates/command_palette/src/command_palette.rs @@ -510,7 +510,7 @@ impl PickerDelegate for CommandPaletteDelegate { .delegate .matches_updated(query, commands, matches, intercept_result, cx) }) - .log_err(); + .ok(); }) } @@ -543,7 +543,7 @@ impl PickerDelegate for CommandPaletteDelegate { fn dismissed(&mut self, _window: &mut Window, cx: &mut Context>) { self.command_palette .update(cx, |_, cx| cx.emit(DismissEvent)) - .log_err(); + .ok(); } fn confirm(&mut self, secondary: bool, window: &mut Window, cx: &mut Context>) { diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index cde04d987a015982006d283c17ee82ed9b7a7cb2..b62f6b5eb60eafb7177f7883b825a208e7c81d62 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -14,6 +14,7 @@ mod persistence; pub mod searchable; mod security_modal; pub mod shared_screen; +use db::smol::future::yield_now; pub use shared_screen::SharedScreen; mod status_bar; pub mod tasks; @@ -2820,13 +2821,15 @@ impl Workspace { .spawn(cx, async move |cx| { // limit to 100 keystrokes to avoid infinite recursion. for _ in 0..100 { - let mut state = keystrokes.borrow_mut(); - let Some(keystroke) = state.queue.pop_front() else { - state.dispatched.clear(); - state.task.take(); - return; + let keystroke = { + let mut state = keystrokes.borrow_mut(); + let Some(keystroke) = state.queue.pop_front() else { + state.dispatched.clear(); + state.task.take(); + return; + }; + keystroke }; - drop(state); cx.update(|window, cx| { let focused = window.focused(cx); window.dispatch_keystroke(keystroke.clone(), cx); @@ -2841,6 +2844,10 @@ impl Workspace { } }) .ok(); + + // Yield between synthetic keystrokes so deferred focus and + // other effects can settle before dispatching the next key. + yield_now().await; } *keystrokes.borrow_mut() = Default::default();