Honor SearchBar being dismissed when changing the active item

This commit is contained in:
Antonio Scandurra 2022-03-29 13:47:48 +02:00
parent 42a7e573bc
commit d7a39a2116

View file

@ -66,7 +66,7 @@ impl View for SearchBar {
} }
fn render(&mut self, cx: &mut RenderContext<Self>) -> ElementBox { fn render(&mut self, cx: &mut RenderContext<Self>) -> ElementBox {
if self.dismissed { if self.dismissed || self.active_editor.is_none() {
Empty::new().boxed() Empty::new().boxed()
} else { } else {
let theme = cx.global::<Settings>().theme.clone(); let theme = cx.global::<Settings>().theme.clone();
@ -129,6 +129,7 @@ impl View for SearchBar {
impl ToolbarItemView for SearchBar { impl ToolbarItemView for SearchBar {
fn set_active_pane_item(&mut self, item: Option<&dyn ItemHandle>, cx: &mut ViewContext<Self>) { fn set_active_pane_item(&mut self, item: Option<&dyn ItemHandle>, cx: &mut ViewContext<Self>) {
cx.notify();
self.active_editor_subscription.take(); self.active_editor_subscription.take();
self.active_editor.take(); self.active_editor.take();
self.pending_search.take(); self.pending_search.take();
@ -139,12 +140,9 @@ impl ToolbarItemView for SearchBar {
Some(cx.subscribe(&editor, Self::on_active_editor_event)); Some(cx.subscribe(&editor, Self::on_active_editor_event));
self.active_editor = Some(editor); self.active_editor = Some(editor);
self.update_matches(false, cx); self.update_matches(false, cx);
self.dismissed = false;
return; return;
} }
} }
self.dismiss(&Dismiss, cx);
} }
} }