diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs index 1ff04a8153b50184ea4a992a0440c5b2d58b64ad..e8629cbb1d53e836eadff4e33a0d4d1655fd69e6 100644 --- a/crates/search/src/project_search.rs +++ b/crates/search/src/project_search.rs @@ -785,14 +785,16 @@ impl ProjectSearchView { ); let focus_handle = cx.focus_handle(); - subscriptions.push(cx.on_focus_in(&focus_handle, window, |this, window, cx| { - if this.focus_handle.is_focused(window) { - if this.has_matches() { - this.results_editor.focus_handle(cx).focus(window); - } else { - this.query_editor.focus_handle(cx).focus(window); + subscriptions.push(cx.on_focus(&focus_handle, window, |_, window, cx| { + cx.on_next_frame(window, |this, window, cx| { + if this.focus_handle.is_focused(window) { + if this.has_matches() { + this.results_editor.focus_handle(cx).focus(window); + } else { + this.query_editor.focus_handle(cx).focus(window); + } } - } + }); })); let languages = project.read(cx).languages().clone();