Change summary
crates/command_palette/src/command_palette.rs | 4 ++--
crates/workspace/src/workspace.rs | 19 +++++++++++++------
2 files changed, 15 insertions(+), 8 deletions(-)
Detailed changes
@@ -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<Picker<Self>>) {
self.command_palette
.update(cx, |_, cx| cx.emit(DismissEvent))
- .log_err();
+ .ok();
}
fn confirm(&mut self, secondary: bool, window: &mut Window, cx: &mut Context<Picker<Self>>) {
@@ -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();