Skip to content

Commit f98b845

Browse files
committed
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.
1 parent e950f99 commit f98b845

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ static char *(features[]) =
761761

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
42,
764766
/**/
765767
41,
766768
/**/

src/window.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,30 +2107,40 @@ win_equal_rec(
21072107
static void
21082108
leaving_window(win_T *win)
21092109
{
2110+
// Only matters for a prompt window.
2111+
if (!bt_prompt(win->w_buffer))
2112+
return;
2113+
21102114
// When leaving a prompt window stop Insert mode and perhaps restart
21112115
// it when entering that window again.
21122116
win->w_buffer->b_prompt_insert = restart_edit;
21132117
restart_edit = NUL;
21142118

21152119
// When leaving the window (or closing the window) was done from a
2116-
// callback we need to break out of the Insert mode loop.
2120+
// callback we need to break out of the Insert mode loop and restart Insert
2121+
// mode when entering the window again.
21172122
if (State & INSERT)
21182123
{
21192124
stop_insert_mode = TRUE;
2120-
if (bt_prompt(win->w_buffer) && win->w_buffer->b_prompt_insert == NUL)
2125+
if (win->w_buffer->b_prompt_insert == NUL)
21212126
win->w_buffer->b_prompt_insert = 'A';
21222127
}
21232128
}
21242129

21252130
static void
21262131
entering_window(win_T *win)
21272132
{
2133+
// Only matters for a prompt window.
2134+
if (!bt_prompt(win->w_buffer))
2135+
return;
2136+
21282137
// When switching to a prompt buffer that was in Insert mode, don't stop
21292138
// Insert mode, it may have been set in leaving_window().
2130-
if (bt_prompt(win->w_buffer) && win->w_buffer->b_prompt_insert != NUL)
2139+
if (win->w_buffer->b_prompt_insert != NUL)
21312140
stop_insert_mode = FALSE;
21322141

2133-
// When entering the prompt window may restart Insert mode.
2142+
// When entering the prompt window restart Insert mode if we were in Insert
2143+
// mode when we left it.
21342144
restart_edit = win->w_buffer->b_prompt_insert;
21352145
}
21362146
#endif

0 commit comments

Comments
 (0)