From d7a39a2116043e363fe2f72f20aecd25a36dc244 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 29 Mar 2022 13:47:48 +0200 Subject: [PATCH] Honor `SearchBar` being dismissed when changing the active item --- crates/search/src/buffer_search.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rs index d1560274c4..36dbbbe7e6 100644 --- a/crates/search/src/buffer_search.rs +++ b/crates/search/src/buffer_search.rs @@ -66,7 +66,7 @@ impl View for SearchBar { } fn render(&mut self, cx: &mut RenderContext) -> ElementBox { - if self.dismissed { + if self.dismissed || self.active_editor.is_none() { Empty::new().boxed() } else { let theme = cx.global::().theme.clone(); @@ -129,6 +129,7 @@ impl View for SearchBar { impl ToolbarItemView for SearchBar { fn set_active_pane_item(&mut self, item: Option<&dyn ItemHandle>, cx: &mut ViewContext) { + cx.notify(); self.active_editor_subscription.take(); self.active_editor.take(); self.pending_search.take(); @@ -139,12 +140,9 @@ impl ToolbarItemView for SearchBar { Some(cx.subscribe(&editor, Self::on_active_editor_event)); self.active_editor = Some(editor); self.update_matches(false, cx); - self.dismissed = false; return; } } - - self.dismiss(&Dismiss, cx); } }