summaryrefslogtreecommitdiff
path: root/helix-term/src/ui
diff options
context:
space:
mode:
authorMichael Davis2022-08-31 16:20:55 +0000
committerGitHub2022-08-31 16:20:55 +0000
commit93c6a337c4f139ce620257fef79f66cf48516d5c (patch)
tree46e4020a50afba2a767dad5104dc73011e5a3594 /helix-term/src/ui
parent83f177d2701b0ec58abcb47c2a1ee133e72342e4 (diff)
Avoid command execution hooks on closed docs (#3613)
Fixes a panic with a config like: [keys.normal.space] x = [":buffer-close"] by bailing out of the command-execution handling if the document doesn't exist after handling a command.
Diffstat (limited to 'helix-term/src/ui')
-rw-r--r--helix-term/src/ui/editor.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index 2de5fe5c..f4e2d13e 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -781,7 +781,10 @@ impl EditorView {
let mut execute_command = |command: &commands::MappableCommand| {
command.execute(cxt);
- let doc = cxt.editor.documents.get_mut(&doc_id).unwrap();
+ let doc = match cxt.editor.documents.get(&doc_id) {
+ Some(doc) => doc,
+ None => return,
+ };
let current_mode = doc.mode();
match (last_mode, current_mode) {
(Mode::Normal, Mode::Insert) => {