on master help sign in
Avoid command execution hooks on closed docs (#3613)
93c6a33Michael Davis
helix-term/src/ui/editor.rs+4−1
@@ -781,7 +781,10 @@ impl EditorView {
781
781
782 let mut execute_command = |command: &commands::MappableCommand| {
782 let mut execute_command = |command: &commands::MappableCommand| {
783 command.execute(cxt);
783 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+ };
785 let current_mode = doc.mode();
788 let current_mode = doc.mode();
786 match (last_mode, current_mode) {
789 match (last_mode, current_mode) {
787 (Mode::Normal, Mode::Insert) => {
790 (Mode::Normal, Mode::Insert) => {