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.
commit93c6a337c4f139ce620257fef79f66cf48516d5c
authorMichael Davis <mcarsondavis@gmail.com>
dateWed 31 Aug 2022, 11:20 (4 years ago)
parent83f177d
helix-term/src/ui/editor.rs+4−1
@@ -781,7 +781,10 @@ impl EditorView {
781781
782782 let mut execute_command = |command: &commands::MappableCommand| {
783783 command.execute(cxt);
784− let doc = cxt.editor.documents.get_mut(&doc_id).unwrap();
784+ let doc = match cxt.editor.documents.get(&doc_id) {
785+ Some(doc) => doc,
786+ None => return,
787+ };
785788 let current_mode = doc.mode();
786789 match (last_mode, current_mode) {
787790 (Mode::Normal, Mode::Insert) => {