Stop crashing if last view is closed.

This commit is contained in:
Blaž Hrastnik 2021-05-03 17:46:14 +09:00
parent 28c167d71d
commit d559199cec

View file

@ -601,11 +601,18 @@ impl Component for EditorView {
mode => self.command_mode(mode, &mut cxt, key), mode => self.command_mode(mode, &mut cxt, key),
} }
} }
self.on_next_key = cxt.on_next_key_callback.take(); self.on_next_key = cxt.on_next_key_callback.take();
self.status_msg = cxt.status_msg.take(); self.status_msg = cxt.status_msg.take();
// appease borrowck // appease borrowck
let callback = cxt.callback.take(); let callback = cxt.callback.take();
// if the command consumed the last view, skip the render.
// on the next loop cycle the Application will then terminate.
if cx.editor.should_close() {
return EventResult::Ignored;
}
let (view, doc) = cx.editor.current(); let (view, doc) = cx.editor.current();
view.ensure_cursor_in_view(doc); view.ensure_cursor_in_view(doc);