vim-patch:9.0.1582: :stopinsert may not work in a popup close handler (#23785)

Problem:    :stopinsert may not work in a popup close handler. (Ben Jackson)
Solution:   Restore stop_insert_mode when appropriate. (closes vim/vim#12452,
            closes vim/vim#12434)

a40c0bcc83
This commit is contained in:
zeertzjq
2023-05-27 22:15:22 +08:00
committed by GitHub
parent 510e1f131b
commit b46f61ac05
2 changed files with 26 additions and 1 deletions

View File

@@ -1355,11 +1355,13 @@ void aucmd_restbuf(aco_save_T *aco)
}
}
win_found:
;
const bool save_stop_insert_mode = stop_insert_mode;
// May need to stop Insert mode if we were in a prompt buffer.
leaving_window(curwin);
// Do not stop Insert mode when already in Insert mode before.
if (aco->save_State & MODE_INSERT) {
stop_insert_mode = false;
stop_insert_mode = save_stop_insert_mode;
}
// Remove the window.
win_remove(curwin, NULL);