changeset 28610:ce202d2984a0 v8.2.4829

patch 8.2.4829: a key may be simplified to NUL Commit: https://github.com/vim/vim/commit/17c95d9608370559441bb73941ba6d9a4b6b26bd Author: zeertzjq <zeertzjq@outlook.com> Date: Tue Apr 26 12:51:07 2022 +0100 patch 8.2.4829: a key may be simplified to NUL Problem: A key may be simplified to NUL. Solution: Use K_ZERO instead. Use macros instead of hard coded values. (closes #10290)
author Bram Moolenaar <Bram@vim.org>
date Tue, 26 Apr 2022 14:00:03 +0200
parents d38d48b0205f
children ab50b921aea6
files src/getchar.c src/misc2.c src/testdir/test_termcodes.vim src/version.c
diffstat 4 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -1637,7 +1637,11 @@ merge_modifyOtherKeys(int c_arg, int *mo
     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;
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -1561,7 +1561,7 @@ extract_modifiers(int key, int *modp, in
 	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;
--- 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
--- 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,