mirror of
https://github.com/neovim/neovim.git
synced 2025-09-26 21:18:34 +00:00
vim-patch:8.2.{4692,4691,4690}: fix Insert mode <LeftDrag> mapping bug (#17999)
vim-patch:8.2.4692: no test for what 8.2.4691 fixes Problem: No test for what 8.2.4691 fixes. Solution: Add a test. Use a more generic sotlution. (closes vim/vim#10090)0f68e6c07a
Test cannot be used because it must use test_setmouse(). Use a Lua test. Reverted patches: vim-patch:8.2.4691: solution for <Cmd> in a mapping causes trouble Problem: Solution for <Cmd> in a mapping causes trouble. Solution: Use another solution: put back CTRL-O after reading the <Cmd> sequence.ca9d8d2cb9
vim-patch:8.2.4689: using <Cmd> in a mapping does not work for mouse keys Problem: Using <Cmd> in a mapping does not work for mouse keys in Insert mode. (Sergey Vlasov) Solution: When reading the <Cmd> argument do not use the stuff buffer. (closes vim/vim#10080)d0fb2d8041
This commit is contained in:
@@ -1253,7 +1253,14 @@ static int old_mod_mask; // mod_mask for ungotten character
|
||||
static int old_mouse_grid; // mouse_grid related to old_char
|
||||
static int old_mouse_row; // mouse_row related to old_char
|
||||
static int old_mouse_col; // mouse_col related to old_char
|
||||
static int old_KeyStuffed; // whether old_char was stuffed
|
||||
|
||||
static bool can_get_old_char(void)
|
||||
{
|
||||
// If the old character was not stuffed and characters have been added to
|
||||
// the stuff buffer, need to first get the stuffed characters instead.
|
||||
return old_char != -1 && (old_KeyStuffed || stuff_empty());
|
||||
}
|
||||
|
||||
/*
|
||||
* Save all three kinds of typeahead, so that the user must type at a prompt.
|
||||
@@ -1454,7 +1461,7 @@ int vgetc(void)
|
||||
* If a character was put back with vungetc, it was already processed.
|
||||
* Return it directly.
|
||||
*/
|
||||
if (old_char != -1) {
|
||||
if (can_get_old_char()) {
|
||||
c = old_char;
|
||||
old_char = -1;
|
||||
mod_mask = old_mod_mask;
|
||||
@@ -1660,7 +1667,7 @@ int plain_vgetc(void)
|
||||
*/
|
||||
int vpeekc(void)
|
||||
{
|
||||
if (old_char != -1) {
|
||||
if (can_get_old_char()) {
|
||||
return old_char;
|
||||
}
|
||||
return vgetorpeek(false);
|
||||
@@ -2052,7 +2059,9 @@ static int handle_mapping(int *keylenp, bool *timedout, int *mapdepth)
|
||||
return map_result_nomatch;
|
||||
}
|
||||
|
||||
// unget one character (can only be done once!)
|
||||
/// unget one character (can only be done once!)
|
||||
/// If the character was stuffed, vgetc() will get it next time it was called.
|
||||
/// Otherwise vgetc() will only get it when the stuff buffer is empty.
|
||||
void vungetc(int c)
|
||||
{
|
||||
old_char = c;
|
||||
@@ -2060,6 +2069,7 @@ void vungetc(int c)
|
||||
old_mouse_grid = mouse_grid;
|
||||
old_mouse_row = mouse_row;
|
||||
old_mouse_col = mouse_col;
|
||||
old_KeyStuffed = KeyStuffed;
|
||||
}
|
||||
|
||||
/// Gets a byte:
|
||||
|
Reference in New Issue
Block a user