fix go to line panic by replacing an unwrap with an and_then

This commit is contained in:
Keith Simmons 2022-03-15 09:31:24 -07:00
parent 40a4c18ee4
commit 72188456b2

View File

@ -59,7 +59,9 @@ impl GoToLine {
}
fn toggle(workspace: &mut Workspace, _: &Toggle, cx: &mut ViewContext<Workspace>) {
if let Some(editor) = workspace.active_item(cx).unwrap().downcast::<Editor>() {
if let Some(editor) = workspace.active_item(cx)
.and_then(|active_item| active_item.downcast::<Editor>())
{
workspace.toggle_modal(cx, |cx, _| {
let view = cx.add_view(|cx| GoToLine::new(editor, cx));
cx.subscribe(&view, Self::on_event).detach();