diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2024-01-19 12:10:31 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-19 12:10:31 +0800 |
| commit | 0ef27180e31671a043b28547da327cd52f1a87c4 (patch) | |
| tree | c27d0a5ab971cc09c1b52400027654488016301f /src | |
| parent | f58c6135084f75e6250fd6b11eac410fb9a21b7a (diff) | |
| parent | 26f836586479239935115944bff1dd2d156ef569 (diff) | |
Merge pull request #27088 from zeertzjq/backportrelease-0.9
Backport to release-0.9
Diffstat (limited to 'src')
| -rw-r--r-- | src/nvim/autocmd.c | 7 | ||||
| -rw-r--r-- | src/nvim/autocmd.h | 2 | ||||
| -rw-r--r-- | src/nvim/edit.c | 2 | ||||
| -rw-r--r-- | src/nvim/ex_getln.c | 9 | ||||
| -rw-r--r-- | src/nvim/window.c | 2 |
5 files changed, 14 insertions, 8 deletions
diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index 5f6bcf14fd..9dd1de04e4 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -1432,9 +1432,11 @@ void aucmd_prepbuf(aco_save_T *aco, buf_T *buf) } aco->save_curwin_handle = curwin->handle; - aco->save_curbuf = curbuf; aco->save_prevwin_handle = prevwin == NULL ? 0 : prevwin->handle; aco->save_State = State; + if (bt_prompt(curbuf)) { + aco->save_prompt_insert = curbuf->b_prompt_insert; + } if (win != NULL) { // There is a window for "buf" in the current tab page, make it the @@ -1547,6 +1549,9 @@ win_found: curbuf = curwin->w_buffer; // May need to restore insert mode for a prompt buffer. entering_window(curwin); + if (bt_prompt(curbuf)) { + curbuf->b_prompt_insert = aco->save_prompt_insert; + } prevwin = win_find_by_handle(aco->save_prevwin_handle); vars_clear(&awp->w_vars->dv_hashtab); // free all w: variables diff --git a/src/nvim/autocmd.h b/src/nvim/autocmd.h index 6dbd18ba7c..10d1aede37 100644 --- a/src/nvim/autocmd.h +++ b/src/nvim/autocmd.h @@ -24,7 +24,6 @@ struct AutoPat_S; // Struct to save values in before executing autocommands for a buffer that is // not the current buffer. typedef struct { - buf_T *save_curbuf; ///< saved curbuf int use_aucmd_win_idx; ///< index in aucmd_win[] if >= 0 handle_T save_curwin_handle; ///< ID of saved curwin handle_T new_curwin_handle; ///< ID of new curwin @@ -33,6 +32,7 @@ typedef struct { char *globaldir; ///< saved value of globaldir bool save_VIsual_active; ///< saved VIsual_active int save_State; ///< saved State + int save_prompt_insert; ///< saved b_prompt_insert } aco_save_T; typedef struct AutoCmd_S AutoCmd; diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 80acabc51d..0cc84966ec 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -393,7 +393,7 @@ static int insert_check(VimState *state) Insstart_orig = Insstart; } - if (curbuf->terminal) { + if (curbuf->terminal && !stop_insert_mode) { // Exit Insert mode and go to Terminal mode. stop_insert_mode = true; restart_edit = 'I'; diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 40d294ca25..0ad105427e 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2252,6 +2252,7 @@ static buf_T *cmdpreview_open_buf(void) /// /// @return Pointer to command preview window if succeeded, NULL if failed. static win_T *cmdpreview_open_win(buf_T *cmdpreview_buf) + FUNC_ATTR_NONNULL_ALL { win_T *save_curwin = curwin; @@ -2523,10 +2524,10 @@ static bool cmdpreview_may_show(CommandLineState *s) cmdpreview_prepare(&cpinfo); // Open preview buffer if inccommand=split. - if (!icm_split) { - cmdpreview_bufnr = 0; - } else if ((cmdpreview_buf = cmdpreview_open_buf()) == NULL) { - abort(); + if (icm_split && (cmdpreview_buf = cmdpreview_open_buf()) == NULL) { + // Failed to create preview buffer, so disable preview. + set_string_option_direct("icm", -1, "nosplit", OPT_FREE, SID_NONE); + icm_split = false; } // Setup preview namespace if it's not already set. if (!cmdpreview_ns) { diff --git a/src/nvim/window.c b/src/nvim/window.c index 7d99aafa5e..0edc2e143a 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -2477,7 +2477,7 @@ void leaving_window(win_T *const win) // When leaving the window (or closing the window) was done from a // callback we need to break out of the Insert mode loop and restart Insert // mode when entering the window again. - if (State & MODE_INSERT) { + if ((State & MODE_INSERT) && !stop_insert_mode) { stop_insert_mode = true; if (win->w_buffer->b_prompt_insert == NUL) { win->w_buffer->b_prompt_insert = 'A'; |
