Skip to content

Commit

Permalink
patch 8.2.4829: a key may be simplified to NUL
Browse files Browse the repository at this point in the history
Problem:    A key may be simplified to NUL.
Solution:   Use K_ZERO instead.  Use macros instead of hard coded values.
            (closes #10290)
  • Loading branch information
zeertzjq authored and brammool committed Apr 26, 2022
1 parent abeb09b commit 17c95d9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/getchar.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/misc2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions src/testdir/test_termcodes.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
4829,
/**/
4828,
/**/
Expand Down

0 comments on commit 17c95d9

Please sign in to comment.