mirror of
https://github.com/neovim/neovim.git
synced 2025-09-13 14:58:18 +00:00
vim-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.
891e1fd894
This commit is contained in:
@@ -5293,6 +5293,9 @@ char_u *buf_spname(buf_T *buf)
|
|||||||
if (buf->b_fname != NULL) {
|
if (buf->b_fname != NULL) {
|
||||||
return buf->b_fname;
|
return buf->b_fname;
|
||||||
}
|
}
|
||||||
|
if (bt_prompt(buf)) {
|
||||||
|
return (char_u *)_("[Prompt]");
|
||||||
|
}
|
||||||
return (char_u *)_("[Scratch]");
|
return (char_u *)_("[Scratch]");
|
||||||
}
|
}
|
||||||
if (buf->b_fname == NULL) {
|
if (buf->b_fname == NULL) {
|
||||||
|
@@ -1151,8 +1151,9 @@ check_pum:
|
|||||||
}
|
}
|
||||||
if (bt_prompt(curbuf)) {
|
if (bt_prompt(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
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1618,6 +1619,8 @@ static void init_prompt(int cmdchar_todo)
|
|||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return TRUE if the cursor is in the editable position of the prompt line.
|
// Return TRUE if the cursor is in the editable position of the prompt line.
|
||||||
@@ -8219,10 +8222,14 @@ static void ins_mouse(int c)
|
|||||||
win_T *new_curwin = curwin;
|
win_T *new_curwin = curwin;
|
||||||
|
|
||||||
if (curwin != old_curwin && win_valid(old_curwin)) {
|
if (curwin != old_curwin && win_valid(old_curwin)) {
|
||||||
/* Mouse took us to another window. We need to go back to the
|
// Mouse took us to another window. We need to go back to the
|
||||||
* 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;
|
||||||
|
if (bt_prompt(curbuf)) {
|
||||||
|
// Restart Insert mode when re-entering the prompt buffer.
|
||||||
|
curbuf->b_prompt_insert = 'A';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
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)) {
|
||||||
|
@@ -45,7 +45,7 @@ describe('prompt buffer', function()
|
|||||||
~ |
|
~ |
|
||||||
~ |
|
~ |
|
||||||
~ |
|
~ |
|
||||||
[Scratch] |
|
[Prompt] |
|
||||||
other buffer |
|
other buffer |
|
||||||
~ |
|
~ |
|
||||||
~ |
|
~ |
|
||||||
@@ -59,7 +59,7 @@ describe('prompt buffer', function()
|
|||||||
Command: "hello" |
|
Command: "hello" |
|
||||||
Result: "hello" |
|
Result: "hello" |
|
||||||
% ^ |
|
% ^ |
|
||||||
[Scratch] |
|
[Prompt] |
|
||||||
other buffer |
|
other buffer |
|
||||||
~ |
|
~ |
|
||||||
~ |
|
~ |
|
||||||
@@ -87,7 +87,7 @@ describe('prompt buffer', function()
|
|||||||
~ |
|
~ |
|
||||||
~ |
|
~ |
|
||||||
~ |
|
~ |
|
||||||
[Scratch] |
|
[Prompt] |
|
||||||
other buffer |
|
other buffer |
|
||||||
~ |
|
~ |
|
||||||
~ |
|
~ |
|
||||||
@@ -101,7 +101,7 @@ describe('prompt buffer', function()
|
|||||||
~ |
|
~ |
|
||||||
~ |
|
~ |
|
||||||
~ |
|
~ |
|
||||||
[Scratch] |
|
[Prompt] |
|
||||||
other buffer |
|
other buffer |
|
||||||
~ |
|
~ |
|
||||||
~ |
|
~ |
|
||||||
@@ -114,7 +114,7 @@ describe('prompt buffer', function()
|
|||||||
~ |
|
~ |
|
||||||
~ |
|
~ |
|
||||||
~ |
|
~ |
|
||||||
[Scratch] |
|
[Prompt] |
|
||||||
other buffer |
|
other buffer |
|
||||||
~ |
|
~ |
|
||||||
~ |
|
~ |
|
||||||
@@ -127,7 +127,7 @@ describe('prompt buffer', function()
|
|||||||
~ |
|
~ |
|
||||||
~ |
|
~ |
|
||||||
~ |
|
~ |
|
||||||
[Scratch] |
|
[Prompt] |
|
||||||
other buffer |
|
other buffer |
|
||||||
~ |
|
~ |
|
||||||
~ |
|
~ |
|
||||||
|
Reference in New Issue
Block a user