Merge pull request #630 from zed-industries/fix/go-to-line-panic

Fix go to line panic by replacing an unwrap with an and_then
This commit is contained in:
Antonio Scandurra 2022-03-15 18:11:26 +01:00 committed by GitHub
commit a0224cbe71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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();