]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1741: Regression with kitty protocol and trailing byte "u" v9.1.1741
authorChristian Brabandt <cb@256bit.org>
Mon, 8 Sep 2025 19:05:13 +0000 (15:05 -0400)
committerChristian Brabandt <cb@256bit.org>
Mon, 8 Sep 2025 19:13:21 +0000 (15:13 -0400)
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 <cb@256bit.org>
src/term.c
src/testdir/test_termcodes.vim
src/version.c

index 2de1508f14010f92c8732a86fcacc01a2f37f97a..aec9559d0e9be7a3d3451d6168e6fbfb43d98676 100644 (file)
@@ -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
index f37f618c8156a43ab3c3035dedf2b4972bfe9967..6fb612e276d0bf65b178bb5d209c233a56495ce8 100644 (file)
@@ -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
 
index 88906bd89822dea0c593eaadb2dc8c66af97a660..adf9f206113aa8202b4079abd810b8a2bc100c52 100644 (file)
@@ -724,6 +724,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1741,
 /**/
     1740,
 /**/