aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Dewar <seandewar@users.noreply.github.com>2021-11-07 14:50:01 +0000
committerSean Dewar <seandewar@users.noreply.github.com>2021-12-07 11:34:26 +0000
commitb9ab4c1dea0ee65950f8c1ec374ccab744a81acb (patch)
treef72a47d75f4c456026c05f26eca4e8d2a78f8180
parentd6ea0741c92e39e4f6c3ec639117d9f39ec08094 (diff)
downloadrneovim-b9ab4c1dea0ee65950f8c1ec374ccab744a81acb.tar.gz
rneovim-b9ab4c1dea0ee65950f8c1ec374ccab744a81acb.tar.bz2
rneovim-b9ab4c1dea0ee65950f8c1ec374ccab744a81acb.zip
vim-patch:8.1.0042: if omni completion opens a window Insert mode is stopped
Problem: If omni completion opens a window Insert mode is stopped. (Hirohito Higashi) Solution: Only set stop_insert_mode in a prompt buffer window. https://github.com/vim/vim/commit/f98b845dd185dfadfa7a622a42452bfa6809d4e0 popupmenu_spec.lua fails without this.
-rw-r--r--src/nvim/window.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 9f4c5c68f6..e0d05e1d47 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -2232,16 +2232,22 @@ static void win_equal_rec(win_T *next_curwin, bool current, frame_T *topfr, int
static void leaving_window(win_T *const win)
FUNC_ATTR_NONNULL_ALL
{
+ // Only matters for a prompt window.
+ if (!bt_prompt(win->w_buffer)) {
+ return;
+ }
+
// 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;
restart_edit = NUL;
// When leaving the window (or closing the window) was done from a
- // callback we need to break out of the Insert mode loop.
+ // callback we need to break out of the Insert mode loop and restart Insert
+ // mode when entering the window again.
if (State & INSERT) {
stop_insert_mode = true;
- if (bt_prompt(win->w_buffer) && win->w_buffer->b_prompt_insert == NUL) {
+ if (win->w_buffer->b_prompt_insert == NUL) {
win->w_buffer->b_prompt_insert = 'A';
}
}
@@ -2250,13 +2256,19 @@ static void leaving_window(win_T *const win)
static void entering_window(win_T *const win)
FUNC_ATTR_NONNULL_ALL
{
+ // Only matters for a prompt window.
+ if (!bt_prompt(win->w_buffer)) {
+ return;
+ }
+
// When switching to a prompt buffer that was in Insert mode, don't stop
// Insert mode, it may have been set in leaving_window().
- if (bt_prompt(win->w_buffer) && win->w_buffer->b_prompt_insert != NUL) {
+ if (win->w_buffer->b_prompt_insert != NUL) {
stop_insert_mode = false;
}
- // When entering the prompt window may restart Insert mode.
+ // When entering the prompt window restart Insert mode if we were in Insert
+ // mode when we left it.
restart_edit = win->w_buffer->b_prompt_insert;
}