mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-11 21:13:02 +00:00
Avoid panic in OutlineView when active item isn't an editor
This commit is contained in:
parent
b7561c6cef
commit
5de5e4b6f2
1 changed files with 17 additions and 18 deletions
|
@ -162,25 +162,24 @@ 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>()
|
let settings = workspace.settings();
|
||||||
.unwrap();
|
let buffer = editor
|
||||||
let settings = workspace.settings();
|
.read(cx)
|
||||||
let buffer = editor
|
.buffer()
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.buffer()
|
.read(cx)
|
||||||
.read(cx)
|
.outline(Some(settings.borrow().theme.editor.syntax.as_ref()));
|
||||||
.read(cx)
|
if let Some(outline) = buffer {
|
||||||
.outline(Some(settings.borrow().theme.editor.syntax.as_ref()));
|
workspace.toggle_modal(cx, |cx, _| {
|
||||||
if let Some(outline) = buffer {
|
let view = cx.add_view(|cx| OutlineView::new(outline, editor, settings, cx));
|
||||||
workspace.toggle_modal(cx, |cx, _| {
|
cx.subscribe(&view, Self::on_event).detach();
|
||||||
let view = cx.add_view(|cx| OutlineView::new(outline, editor, settings, cx));
|
view
|
||||||
cx.subscribe(&view, Self::on_event).detach();
|
})
|
||||||
view
|
}
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue