From d559199cecb105e07d9812603889a469d415e8b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Mon, 3 May 2021 17:46:14 +0900 Subject: [PATCH] Stop crashing if last view is closed. --- helix-term/src/ui/editor.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 13ac88fd0..041096d62 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -601,11 +601,18 @@ impl Component for EditorView { mode => self.command_mode(mode, &mut cxt, key), } } + self.on_next_key = cxt.on_next_key_callback.take(); self.status_msg = cxt.status_msg.take(); // appease borrowck 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(); view.ensure_cursor_in_view(doc);