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.
imgbot
Michael Davis 2 years ago committed by GitHub
parent 83f177d270
commit 93c6a337c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -781,7 +781,10 @@ impl EditorView {
let mut execute_command = |command: &commands::MappableCommand| { let mut execute_command = |command: &commands::MappableCommand| {
command.execute(cxt); 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(); let current_mode = doc.mode();
match (last_mode, current_mode) { match (last_mode, current_mode) {
(Mode::Normal, Mode::Insert) => { (Mode::Normal, Mode::Insert) => {

Loading…
Cancel
Save