diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-12-29 20:53:33 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-12-29 20:53:33 +0100 |
commit | 4d8c96d4668ac965d4e84b9676fba6d7efe62a32 (patch) | |
tree | acaaada4eddf51350a21b7d2263121fae2a29c92 /src/term.c | |
parent | 285b15fce164ade8b1537b884cc15aebaa60e9ef (diff) | |
download | vim-git-4d8c96d4668ac965d4e84b9676fba6d7efe62a32.tar.gz |
patch 8.2.2246: cursor keys not recognized at the hit-Enter promptv8.2.2246
Problem: Cursor keys not recognized at the hit-Enter prompt after executing
an external command.
Solution: Change the codes for the extra cursor keys. (closes #7562)
Tune the delays to avoid test flakyness.
Diffstat (limited to 'src/term.c')
-rw-r--r-- | src/term.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/term.c b/src/term.c index 26031723d..b55d39577 100644 --- a/src/term.c +++ b/src/term.c @@ -914,10 +914,10 @@ static struct builtin_term builtin_termcaps[] = {K_RIGHT, IF_EB("\033O*C", ESC_STR "O*C")}, {K_LEFT, IF_EB("\033O*D", ESC_STR "O*D")}, // An extra set of cursor keys for vt100 mode - {K_XUP, IF_EB("\033[1;*A", ESC_STR "[1;*A")}, - {K_XDOWN, IF_EB("\033[1;*B", ESC_STR "[1;*B")}, - {K_XRIGHT, IF_EB("\033[1;*C", ESC_STR "[1;*C")}, - {K_XLEFT, IF_EB("\033[1;*D", ESC_STR "[1;*D")}, + {K_XUP, IF_EB("\033[@;*A", ESC_STR "[@;*A")}, + {K_XDOWN, IF_EB("\033[@;*B", ESC_STR "[@;*B")}, + {K_XRIGHT, IF_EB("\033[@;*C", ESC_STR "[@;*C")}, + {K_XLEFT, IF_EB("\033[@;*D", ESC_STR "[@;*D")}, // An extra set of function keys for vt100 mode {K_XF1, IF_EB("\033O*P", ESC_STR "O*P")}, {K_XF2, IF_EB("\033O*Q", ESC_STR "O*Q")}, @@ -4230,7 +4230,12 @@ add_termcode(char_u *name, char_u *string, int flags) termcodes[i].modlen = 0; j = termcode_star(s, len); if (j > 0) + { termcodes[i].modlen = len - 1 - j; + // For "CSI[@;X" the "@" is not included in "modlen". + if (termcodes[i].code[termcodes[i].modlen - 1] == '@') + --termcodes[i].modlen; + } ++tc_len; } @@ -4242,7 +4247,7 @@ add_termcode(char_u *name, char_u *string, int flags) static int termcode_star(char_u *code, int len) { - // Shortest is <M-O>*X. With ; shortest is <CSI>1;*X + // Shortest is <M-O>*X. With ; shortest is <CSI>@;*X if (len >= 3 && code[len - 2] == '*') { if (len >= 5 && code[len - 3] == ';') @@ -5329,15 +5334,19 @@ check_termcode( /* * Check for code with modifier, like xterm uses: * <Esc>[123;*X (modslen == slen - 3) + * <Esc>[@;*X (matches <Esc>[X and <Esc>[1;9X ) * Also <Esc>O*X and <M-O>*X (modslen == slen - 2). * When there is a modifier the * matches a number. * When there is no modifier the ;* or * is omitted. */ if (termcodes[idx].modlen > 0) { + int at_code; + modslen = termcodes[idx].modlen; if (cpo_koffset && offset && len < modslen) continue; + at_code = termcodes[idx].code[modslen] == '@'; if (STRNCMP(termcodes[idx].code, tp, (size_t)(modslen > len ? len : modslen)) == 0) { @@ -5347,9 +5356,14 @@ check_termcode( return -1; // need to get more chars if (tp[modslen] == termcodes[idx].code[slen - 1]) - slen = modslen + 1; // no modifiers + // no modifiers + slen = modslen + 1; else if (tp[modslen] != ';' && modslen == slen - 3) - continue; // no match + // no match for "code;*X" with "code;" + continue; + else if (at_code && tp[modslen] != '1') + // no match for "<Esc>[@" with "<Esc>[1" + continue; else { // Skip over the digits, the final char must |