From 1fffccc5d62e4fa01c1ce52405da359723defb1c Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Sun, 7 Nov 2021 20:57:09 +0000 Subject: vim-patch:8.1.0064: typing CTRL-W in a prompt buffer shows mode "-- --" Problem: Typing CTRL-W in a prompt buffer shows mode "-- --". Solution: Set restart_edit to 'A' and check for it. https://github.com/vim/vim/commit/942b4541a2d8e8df8369ab70e112dbbbe0c7c0aa Nvim already checked for 'i' in showmode(), so this bug was fixed with (though this patch now changes to use 'A'). However, the missing changes I ported for v8.1.0036 use 'A' when a callback leaves the window in insert mode and edit gets restarted, so this bug was possible there. Modify showmode() restart_edit condition to match v8.2.1978: https://github.com/vim/vim/commit/957cf67d50516ba98716f59c9e1cb6412ec1535d --- src/nvim/edit.c | 2 +- src/nvim/screen.c | 4 ++-- src/nvim/window.c | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 16601d327d..6e3efe8bba 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -995,7 +995,7 @@ static int insert_handle_key(InsertState *s) // In a prompt window CTRL-W is used for window commands. // Use Shift-CTRL-W to delete a word. stuffcharReadbuff(Ctrl_W); - restart_edit = 'i'; + restart_edit = 'A'; s->nomove = true; s->count = 0; return 0; diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 2ce2be0bfd..d015ef110e 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -6930,7 +6930,7 @@ int showmode(void) do_mode = ((p_smd && msg_silent == 0) && ((State & TERM_FOCUS) || (State & INSERT) - || restart_edit + || restart_edit != NUL || VIsual_active)); if (do_mode || reg_recording != 0) { // Don't show mode right now, when not redrawing or inside a mapping. @@ -7010,7 +7010,7 @@ int showmode(void) } msg_puts_attr(_(" INSERT"), attr); } else if (restart_edit == 'I' || restart_edit == 'i' - || restart_edit == 'a') { + || restart_edit == 'a' || restart_edit == 'A') { msg_puts_attr(_(" (insert)"), attr); } else if (restart_edit == 'R') { msg_puts_attr(_(" (replace)"), attr); diff --git a/src/nvim/window.c b/src/nvim/window.c index e0d05e1d47..ddf50b47a7 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -2240,6 +2240,9 @@ static void leaving_window(win_T *const win) // When leaving a prompt window stop Insert mode and perhaps restart // it when entering that window again. win->w_buffer->b_prompt_insert = restart_edit; + if (restart_edit != NUL && mode_displayed) { + clear_cmdline = true; // unshow mode later + } restart_edit = NUL; // When leaving the window (or closing the window) was done from a -- cgit