From eceb43e1aee4b671a21fcbca56fba714f2ed763e Mon Sep 17 00:00:00 2001 From: feeiyu Date: Sun, 29 Dec 2024 20:16:47 +0800 Subject: [PATCH] fix lost focus issue --- crates/search/src/project_search.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs index 9272d99524792..e2e5bc4823825 100644 --- a/crates/search/src/project_search.rs +++ b/crates/search/src/project_search.rs @@ -744,14 +744,16 @@ impl ProjectSearchView { ); let focus_handle = cx.focus_handle(); - subscriptions.push(cx.on_focus_in(&focus_handle, |this, cx| { - if this.focus_handle.is_focused(cx) { - if this.has_matches() { - this.results_editor.focus_handle(cx).focus(cx); - } else { - this.query_editor.focus_handle(cx).focus(cx); + subscriptions.push(cx.on_focus(&focus_handle, |_, cx| { + cx.on_next_frame(|this, cx| { + if this.focus_handle.is_focused(cx) { + if this.has_matches() { + this.results_editor.focus_handle(cx).focus(cx); + } else { + this.query_editor.focus_handle(cx).focus(cx); + } } - } + }); })); // Check if Worktrees have all been previously indexed