Skip to content

Commit 4ed19fd

Browse files
committed
patch 9.1.1741: Regression with kitty protocol and trailing byte "u"
Problem: Regression with kitty protocol and trailing byte "u" (chdiza, after v9.1.1736) Solution: Check that trailing byte "~" is present fixes: #18232 closes: #18234 Signed-off-by: Christian Brabandt <[email protected]>
1 parent c7f235b commit 4ed19fd

3 files changed

Lines changed: 25 additions & 9 deletions

File tree

src/term.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5338,7 +5338,8 @@ handle_key_with_modifier(
53385338
char_u *buf,
53395339
int bufsize,
53405340
int *buflen,
5341-
int iskitty)
5341+
int iskitty,
5342+
int trail)
53425343
{
53435344
// Only set seenModifyOtherKeys for the "{lead}27;" code to avoid setting
53445345
// it for terminals using the kitty keyboard protocol. Xterm sends
@@ -5376,11 +5377,11 @@ handle_key_with_modifier(
53765377
if (key == ESC)
53775378
key = K_ESC;
53785379

5379-
else if (arg[0] >= 11 && arg[0] <= 24)
5380+
else if (arg[0] >= 11 && arg[0] <= 24 && trail == '~')
53805381
key = parse_csi_f_keys(arg[0]);
53815382

5382-
return put_key_modifiers_in_typebuf(key, modifiers,
5383-
csi_len, offset, buf, bufsize, buflen);
5383+
return put_key_modifiers_in_typebuf(key, modifiers, csi_len, offset, buf,
5384+
bufsize, buflen);
53845385
}
53855386

53865387
/*
@@ -5396,7 +5397,8 @@ handle_key_without_modifier(
53965397
int offset,
53975398
char_u *buf,
53985399
int bufsize,
5399-
int *buflen)
5400+
int *buflen,
5401+
int trail)
54005402
{
54015403
char_u string[MAX_KEY_CODE_LEN + 1];
54025404
int new_slen;
@@ -5410,7 +5412,7 @@ handle_key_without_modifier(
54105412
string[2] = KE_ESC;
54115413
new_slen = 3;
54125414
}
5413-
else if (arg[0] >= 11 && arg[0] <= 24)
5415+
else if (arg[0] >= 11 && arg[0] <= 24 && trail == '~')
54145416
{
54155417
int key = parse_csi_f_keys(arg[0]);
54165418
string[0] = K_SPECIAL;
@@ -5724,16 +5726,16 @@ handle_csi(
57245726
{
57255727
int iskitty = argc == 2 && (trail == 'u' || trail == '~');
57265728
return len + handle_key_with_modifier(arg, csi_len, offset, buf,
5727-
bufsize, buflen, iskitty);
5729+
bufsize, buflen, iskitty, trail);
57285730
}
57295731

57305732
// Key without modifier (Kitty sends this for Esc or F3):
57315733
// {lead}{key}u
57325734
// {lead}{key}~
57335735
else if (argc == 1 && (trail == 'u' || trail == '~'))
57345736
{
5735-
return len + handle_key_without_modifier(arg,
5736-
csi_len, offset, buf, bufsize, buflen);
5737+
return len + handle_key_without_modifier(arg, csi_len, offset, buf,
5738+
bufsize, buflen, trail);
57375739
}
57385740

57395741
// else: Unknown CSI sequence. We could drop it, but then the

src/testdir/test_termcodes.vim

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2542,6 +2542,18 @@ func Test_mapping_kitty_function_keys2()
25422542
set timeoutlen&
25432543
endfunc
25442544

2545+
func Test_mapping_kitty_shift_enter()
2546+
new
2547+
set timeoutlen=10
2548+
2549+
imap <buffer> <S-CR> YYYY
2550+
call feedkeys(printf("i123 %s\<esc>", GetEscCodeCSIu("\<cr>", 2)),'Lx!')
2551+
call assert_equal('123 YYYY', getline(1))
2552+
2553+
bwipe!
2554+
set timeoutlen&
2555+
endfunc
2556+
25452557
func Test_insert_literal()
25462558
set timeoutlen=10
25472559

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,8 @@ static char *(features[]) =
724724

725725
static int included_patches[] =
726726
{ /* Add new patch number below this line */
727+
/**/
728+
1741,
727729
/**/
728730
1740,
729731
/**/

0 commit comments

Comments
 (0)