summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-04-26 12:51:07 +0100
committerBram Moolenaar <Bram@vim.org>2022-04-26 12:51:07 +0100
commit17c95d9608370559441bb73941ba6d9a4b6b26bd (patch)
tree35b1f01870169d44d32a5f5d4eb04264fc6ca664
parentabeb09b2c53054513812d1e56716e2a5abe8f354 (diff)
downloadvim-git-8.2.4829.tar.gz
patch 8.2.4829: a key may be simplified to NULv8.2.4829
Problem: A key may be simplified to NUL. Solution: Use K_ZERO instead. Use macros instead of hard coded values. (closes #10290)
-rw-r--r--src/getchar.c6
-rw-r--r--src/misc2.c2
-rw-r--r--src/testdir/test_termcodes.vim6
-rw-r--r--src/version.c2
4 files changed, 14 insertions, 2 deletions
diff --git a/src/getchar.c b/src/getchar.c
index 73cf4208b..4caa89eb3 100644
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -1637,7 +1637,11 @@ merge_modifyOtherKeys(int c_arg, int *modifiers)
if (*modifiers & MOD_MASK_CTRL)
{
if ((c >= '`' && c <= 0x7f) || (c >= '@' && c <= '_'))
+ {
c &= 0x1f;
+ if (c == NUL)
+ c = K_ZERO;
+ }
else if (c == '6')
// CTRL-6 is equivalent to CTRL-^
c = 0x1e;
@@ -3661,7 +3665,7 @@ inchar(
for (;;)
{
len = ui_inchar(dum, DUM_LEN, 0L, 0);
- if (len == 0 || (len == 1 && dum[0] == 3))
+ if (len == 0 || (len == 1 && dum[0] == Ctrl_C))
break;
}
return retesc;
diff --git a/src/misc2.c b/src/misc2.c
index c23c689c0..6641a27c7 100644
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -1561,7 +1561,7 @@ extract_modifiers(int key, int *modp, int simplify, int *did_simplify)
key = Ctrl_chr(key);
modifiers &= ~MOD_MASK_CTRL;
// <C-@> is <Nul>
- if (key == 0)
+ if (key == NUL)
key = K_ZERO;
if (did_simplify != NULL)
*did_simplify = TRUE;
diff --git a/src/testdir/test_termcodes.vim b/src/testdir/test_termcodes.vim
index 6e4bbd19c..ddbe707d1 100644
--- a/src/testdir/test_termcodes.vim
+++ b/src/testdir/test_termcodes.vim
@@ -2437,5 +2437,11 @@ func Test_terminal_builtin_without_gui()
call assert_notequal(-1, index(output, 'builtin_dumb'))
endfunc
+func Test_simplify_ctrl_at()
+ " feeding unsimplified CTRL-@ should still trigger i_CTRL-@
+ call feedkeys("ifoo\<Esc>A\<*C-@>", 'xt')
+ call assert_equal('foofoo', getline(1))
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index 945b6a18a..54f350bf8 100644
--- a/src/version.c
+++ b/src/version.c
@@ -747,6 +747,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 4829,
+/**/
4828,
/**/
4827,