Commit: patch 9.1.1741: Regression with kitty protocol and trailing byte "u"

5 views
Skip to first unread message

Christian Brabandt

unread,
Sep 8, 2025, 3:15:18 PMSep 8
to vim...@googlegroups.com
patch 9.1.1741: Regression with kitty protocol and trailing byte "u"

Commit: https://github.com/vim/vim/commit/4ed19fd336c4672989170992c3fe53cc74392476
Author: Christian Brabandt <c...@256bit.org>
Date: Mon Sep 8 15:05:13 2025 -0400

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 <c...@256bit.org>

diff --git a/src/term.c b/src/term.c
index 2de1508f1..aec9559d0 100644
--- a/src/term.c
+++ b/src/term.c
@@ -5338,7 +5338,8 @@ handle_key_with_modifier(
char_u *buf,
int bufsize,
int *buflen,
- int iskitty)
+ int iskitty,
+ int trail)
{
// Only set seenModifyOtherKeys for the "{lead}27;" code to avoid setting
// it for terminals using the kitty keyboard protocol. Xterm sends
@@ -5376,11 +5377,11 @@ handle_key_with_modifier(
if (key == ESC)
key = K_ESC;

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

- return put_key_modifiers_in_typebuf(key, modifiers,
- csi_len, offset, buf, bufsize, buflen);
+ return put_key_modifiers_in_typebuf(key, modifiers, csi_len, offset, buf,
+ bufsize, buflen);
}

/*
@@ -5396,7 +5397,8 @@ handle_key_without_modifier(
int offset,
char_u *buf,
int bufsize,
- int *buflen)
+ int *buflen,
+ int trail)
{
char_u string[MAX_KEY_CODE_LEN + 1];
int new_slen;
@@ -5410,7 +5412,7 @@ handle_key_without_modifier(
string[2] = KE_ESC;
new_slen = 3;
}
- else if (arg[0] >= 11 && arg[0] <= 24)
+ else if (arg[0] >= 11 && arg[0] <= 24 && trail == '~')
{
int key = parse_csi_f_keys(arg[0]);
string[0] = K_SPECIAL;
@@ -5724,7 +5726,7 @@ handle_csi(
{
int iskitty = argc == 2 && (trail == 'u' || trail == '~');
return len + handle_key_with_modifier(arg, csi_len, offset, buf,
- bufsize, buflen, iskitty);
+ bufsize, buflen, iskitty, trail);
}

// Key without modifier (Kitty sends this for Esc or F3):
@@ -5732,8 +5734,8 @@ handle_csi(
// {lead}{key}~
else if (argc == 1 && (trail == 'u' || trail == '~'))
{
- return len + handle_key_without_modifier(arg,
- csi_len, offset, buf, bufsize, buflen);
+ return len + handle_key_without_modifier(arg, csi_len, offset, buf,
+ bufsize, buflen, trail);
}

// else: Unknown CSI sequence. We could drop it, but then the
diff --git a/src/testdir/test_termcodes.vim b/src/testdir/test_termcodes.vim
index f37f618c8..6fb612e27 100644
--- a/src/testdir/test_termcodes.vim
+++ b/src/testdir/test_termcodes.vim
@@ -2542,6 +2542,18 @@ func Test_mapping_kitty_function_keys2()
set timeoutlen&
endfunc

+func Test_mapping_kitty_shift_enter()
+ new
+ set timeoutlen=10
+
+ imap <buffer> <S-CR> YYYY
+ call feedkeys(printf("i123 %s\<esc>", GetEscCodeCSIu("\<cr>", 2)),'Lx!')
+ call assert_equal('123 YYYY', getline(1))
+
+ bwipe!
+ set timeoutlen&
+endfunc
+
func Test_insert_literal()
set timeoutlen=10

diff --git a/src/version.c b/src/version.c
index 88906bd89..adf9f2061 100644
--- a/src/version.c
+++ b/src/version.c
@@ -724,6 +724,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1741,
/**/
1740,
/**/
Reply all
Reply to author
Forward
0 new messages