summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-06-10 14:39:52 +0200
committerBram Moolenaar <Bram@vim.org>2018-06-10 14:39:52 +0200
commitf98b845dd185dfadfa7a622a42452bfa6809d4e0 (patch)
tree648d1b89a1e7b4120bfabc66eb6d5da18e46dbe6
parente950f9992b291a07e4fb41cb561156f5b382cd5d (diff)
patch 8.1.0042: if omni completion opens a window Insert mode is stoppedv8.1.0042
Problem: If omni completion opens a window Insert mode is stopped. (Hirohito Higashi) Solution: Only set stop_insert_mode in a prompt buffer window.
-rw-r--r--src/version.c2
-rw-r--r--src/window.c18
2 files changed, 16 insertions, 4 deletions
diff --git a/src/version.c b/src/version.c
index 71283ed0db..4ab241eb90 100644
--- a/src/version.c
+++ b/src/version.c
@@ -762,6 +762,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 42,
+/**/
41,
/**/
40,
diff --git a/src/window.c b/src/window.c
index 27ef9d5cc2..74e3c04698 100644
--- a/src/window.c
+++ b/src/window.c
@@ -2107,17 +2107,22 @@ win_equal_rec(
static void
leaving_window(win_T *win)
{
+ // 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';
}
}
@@ -2125,12 +2130,17 @@ leaving_window(win_T *win)
static void
entering_window(win_T *win)
{
+ // 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;
}
#endif