#ifdef FEAT_JOB_CHANNEL
if (bt_prompt(curbuf))
{
- buf_T *buf = curbuf;
-
invoke_prompt_callback();
- if (curbuf != buf)
- // buffer changed, get out of Insert mode
+ if (!bt_prompt(curbuf))
+ // buffer changed to a non-prompt buffer, get out of
+ // Insert mode
goto doESCkey;
break;
}
coladvance((colnr_T)MAXCOL);
if (cmdchar_todo == 'I' || curwin->w_cursor.col <= (int)STRLEN(prompt))
curwin->w_cursor.col = STRLEN(prompt);
+ /* Make sure the cursor is in a valid position. */
+ check_cursor();
}
/*
/* If deleted before the insertion point, adjust it */
if (curwin->w_cursor.lnum == Insstart_orig.lnum
- && curwin->w_cursor.col < Insstart_orig.col)
+ && curwin->w_cursor.col < Insstart_orig.col)
Insstart_orig.col = curwin->w_cursor.col;
/* vi behaviour: the cursor moves backward but the character that
* previous one to stop insert there properly. */
curwin = old_curwin;
curbuf = curwin->w_buffer;
+#ifdef FEAT_JOB_CHANNEL
+ if (bt_prompt(curbuf))
+ // Restart Insert mode when re-entering the prompt buffer.
+ curbuf->b_prompt_insert = 'A';
+#endif
}
start_arrow(curwin == old_curwin ? &tpos : NULL);
if (curwin != new_curwin && win_valid(new_curwin))
// When leaving the window (or closing the window) was done from a
// callback we need to break out of the Insert mode loop.
if (State & INSERT)
+ {
stop_insert_mode = TRUE;
+ if (bt_prompt(win->w_buffer) && win->w_buffer->b_prompt_insert == NUL)
+ win->w_buffer->b_prompt_insert = 'A';
+ }
}
static void
entering_window(win_T *win)
{
+ // 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)
+ stop_insert_mode = FALSE;
+
// When entering the prompt window may restart Insert mode.
restart_edit = win->w_buffer->b_prompt_insert;
}