Merge pull request #795 from zed-industries/cancel-buffer-search
Handle editor cancel in pane in order to dismiss find toolbar
This commit is contained in:
@@ -41,6 +41,7 @@ pub fn init(cx: &mut MutableAppContext) {
|
||||
cx.add_action(BufferSearchBar::select_prev_match);
|
||||
cx.add_action(BufferSearchBar::select_next_match_on_pane);
|
||||
cx.add_action(BufferSearchBar::select_prev_match_on_pane);
|
||||
cx.add_action(BufferSearchBar::handle_editor_cancel);
|
||||
}
|
||||
|
||||
pub struct BufferSearchBar {
|
||||
@@ -333,6 +334,16 @@ impl BufferSearchBar {
|
||||
cx.propagate_action();
|
||||
}
|
||||
|
||||
fn handle_editor_cancel(pane: &mut Pane, _: &editor::Cancel, cx: &mut ViewContext<Pane>) {
|
||||
if let Some(search_bar) = pane.toolbar().read(cx).item_of_type::<BufferSearchBar>() {
|
||||
if !search_bar.read(cx).dismissed {
|
||||
search_bar.update(cx, |search_bar, cx| search_bar.dismiss(&Dismiss, cx));
|
||||
return;
|
||||
}
|
||||
}
|
||||
cx.propagate_action();
|
||||
}
|
||||
|
||||
fn focus_editor(&mut self, _: &FocusEditor, cx: &mut ViewContext<Self>) {
|
||||
if let Some(active_editor) = self.active_editor.as_ref() {
|
||||
cx.focus(active_editor);
|
||||
|
||||
Reference in New Issue
Block a user