mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.1.0036: not restoring Insert mode if leaving prompt buffer with mouse
Problem: Not restoring Insert mode if leaving a prompt buffer by using a mouse click. Solution: Set b_prompt_insert appropriately. Also correct cursor position when moving cursor to last line.
This commit is contained in:
@@ -5733,6 +5733,10 @@ buf_spname(buf_T *buf)
|
|||||||
#endif
|
#endif
|
||||||
if (buf->b_fname != NULL)
|
if (buf->b_fname != NULL)
|
||||||
return buf->b_fname;
|
return buf->b_fname;
|
||||||
|
#ifdef FEAT_JOB_CHANNEL
|
||||||
|
if (bt_prompt(buf))
|
||||||
|
return (char_u *)_("[Prompt]");
|
||||||
|
#endif
|
||||||
return (char_u *)_("[Scratch]");
|
return (char_u *)_("[Scratch]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
16
src/edit.c
16
src/edit.c
@@ -1411,11 +1411,10 @@ doESCkey:
|
|||||||
#ifdef FEAT_JOB_CHANNEL
|
#ifdef FEAT_JOB_CHANNEL
|
||||||
if (bt_prompt(curbuf))
|
if (bt_prompt(curbuf))
|
||||||
{
|
{
|
||||||
buf_T *buf = curbuf;
|
|
||||||
|
|
||||||
invoke_prompt_callback();
|
invoke_prompt_callback();
|
||||||
if (curbuf != buf)
|
if (!bt_prompt(curbuf))
|
||||||
// buffer changed, get out of Insert mode
|
// buffer changed to a non-prompt buffer, get out of
|
||||||
|
// Insert mode
|
||||||
goto doESCkey;
|
goto doESCkey;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1906,6 +1905,8 @@ init_prompt(int cmdchar_todo)
|
|||||||
coladvance((colnr_T)MAXCOL);
|
coladvance((colnr_T)MAXCOL);
|
||||||
if (cmdchar_todo == 'I' || curwin->w_cursor.col <= (int)STRLEN(prompt))
|
if (cmdchar_todo == 'I' || curwin->w_cursor.col <= (int)STRLEN(prompt))
|
||||||
curwin->w_cursor.col = STRLEN(prompt);
|
curwin->w_cursor.col = STRLEN(prompt);
|
||||||
|
/* Make sure the cursor is in a valid position. */
|
||||||
|
check_cursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -9467,7 +9468,7 @@ ins_bs(
|
|||||||
|
|
||||||
/* If deleted before the insertion point, adjust it */
|
/* If deleted before the insertion point, adjust it */
|
||||||
if (curwin->w_cursor.lnum == Insstart_orig.lnum
|
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;
|
Insstart_orig.col = curwin->w_cursor.col;
|
||||||
|
|
||||||
/* vi behaviour: the cursor moves backward but the character that
|
/* vi behaviour: the cursor moves backward but the character that
|
||||||
@@ -9517,6 +9518,11 @@ ins_mouse(int c)
|
|||||||
* previous one to stop insert there properly. */
|
* previous one to stop insert there properly. */
|
||||||
curwin = old_curwin;
|
curwin = old_curwin;
|
||||||
curbuf = curwin->w_buffer;
|
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);
|
start_arrow(curwin == old_curwin ? &tpos : NULL);
|
||||||
if (curwin != new_curwin && win_valid(new_curwin))
|
if (curwin != new_curwin && win_valid(new_curwin))
|
||||||
|
@@ -761,6 +761,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
36,
|
||||||
/**/
|
/**/
|
||||||
35,
|
35,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -2115,12 +2115,21 @@ leaving_window(win_T *win)
|
|||||||
// When leaving the window (or closing the window) was done from a
|
// 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.
|
||||||
if (State & INSERT)
|
if (State & INSERT)
|
||||||
|
{
|
||||||
stop_insert_mode = TRUE;
|
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
|
static void
|
||||||
entering_window(win_T *win)
|
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.
|
// When entering the prompt window may restart Insert mode.
|
||||||
restart_edit = win->w_buffer->b_prompt_insert;
|
restart_edit = win->w_buffer->b_prompt_insert;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user