summaryrefslogtreecommitdiff
path: root/src/term.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-01-30 15:39:47 +0100
committerBram Moolenaar <Bram@vim.org>2021-01-30 15:39:47 +0100
commit92e5df804719d2e6cb8145c2b098aa8d6f3dd252 (patch)
treee36749038c1b395617a08555503e85c744866a84 /src/term.c
parent3eb6bd9c2b36dcce471bfb543c8d5488f1dc17a4 (diff)
downloadvim-git-92e5df804719d2e6cb8145c2b098aa8d6f3dd252.tar.gz
patch 8.2.2428: FocusGained does not work when 'ttymouse' is emptyv8.2.2428
Problem: FocusGained does not work when 'ttymouse' is empty. Solution: Don't use the short mouse code if there is a longer matching code. (closes #7755) Add a test.
Diffstat (limited to 'src/term.c')
-rw-r--r--src/term.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/src/term.c b/src/term.c
index 47e5dfd1e..144055028 100644
--- a/src/term.c
+++ b/src/term.c
@@ -5339,6 +5339,8 @@ check_termcode(
else
#endif // FEAT_GUI
{
+ int mouse_index_found = -1;
+
for (idx = 0; idx < tc_len; ++idx)
{
/*
@@ -5376,9 +5378,24 @@ check_termcode(
}
}
- key_name[0] = termcodes[idx].name[0];
- key_name[1] = termcodes[idx].name[1];
- break;
+ // The mouse termcode "ESC [" is also the prefix of
+ // "ESC [ I" (focus gained). Only use it when there is
+ // no other match. Do use it when a digit is following to
+ // avoid waiting for more bytes.
+ if (slen == 2 && len > 2
+ && termcodes[idx].code[0] == ESC
+ && termcodes[idx].code[1] == '['
+ && !isdigit(tp[2]))
+ {
+ if (mouse_index_found < 0)
+ mouse_index_found = idx;
+ }
+ else
+ {
+ key_name[0] = termcodes[idx].name[0];
+ key_name[1] = termcodes[idx].name[1];
+ break;
+ }
}
/*
@@ -5389,7 +5406,7 @@ check_termcode(
* When there is a modifier the * matches a number.
* When there is no modifier the ;* or * is omitted.
*/
- if (termcodes[idx].modlen > 0)
+ if (termcodes[idx].modlen > 0 && mouse_index_found < 0)
{
int at_code;
@@ -5442,6 +5459,11 @@ check_termcode(
}
}
}
+ if (idx == tc_len && mouse_index_found >= 0)
+ {
+ key_name[0] = termcodes[mouse_index_found].name[0];
+ key_name[1] = termcodes[mouse_index_found].name[1];
+ }
}
#ifdef FEAT_TERMRESPONSE