Skip to content

Commit

Permalink
Avoid command execution hooks on closed docs (helix-editor#3613)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
the-mikedavis authored and thomasskk committed Sep 9, 2022
1 parent b3519b8 commit 20334a4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion helix-term/src/ui/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,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) => {
Expand Down

0 comments on commit 20334a4

Please sign in to comment.