Avoid panic in OutlineView when active item isn't an editor

This commit is contained in:
Max Brunsfeld 2022-01-14 10:51:26 -08:00
parent b7561c6cef
commit 5de5e4b6f2

View file

@ -162,12 +162,10 @@ impl OutlineView {
} }
fn toggle(workspace: &mut Workspace, _: &Toggle, cx: &mut ViewContext<Workspace>) { fn toggle(workspace: &mut Workspace, _: &Toggle, cx: &mut ViewContext<Workspace>) {
let editor = workspace if let Some(editor) = workspace
.active_item(cx) .active_item(cx)
.unwrap() .and_then(|item| item.to_any().downcast::<Editor>())
.to_any() {
.downcast::<Editor>()
.unwrap();
let settings = workspace.settings(); let settings = workspace.settings();
let buffer = editor let buffer = editor
.read(cx) .read(cx)
@ -183,6 +181,7 @@ impl OutlineView {
}) })
} }
} }
}
fn select_prev(&mut self, _: &SelectPrev, cx: &mut ViewContext<Self>) { fn select_prev(&mut self, _: &SelectPrev, cx: &mut ViewContext<Self>) {
if self.selected_match_index > 0 { if self.selected_match_index > 0 {