]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0788: <CSI>27;<mod>u is not decoded to literal Escape in kitty/foot v9.1.0788
authorChristian Fillion <contact@cfillion.ca>
Wed, 16 Oct 2024 15:28:38 +0000 (17:28 +0200)
committerChristian Brabandt <cb@256bit.org>
Wed, 16 Oct 2024 15:28:38 +0000 (17:28 +0200)
Problem:  <CSI>27;<mod>u is not decoded to literal Escape in kitty/foot
Solution: disable XTerm modifyOtherKeys form 1 when the kitty protocol is enabled
          (Christian Fillion)

References:
- https://invisible-island.net/xterm/modified-keys.html
- https://sw.kovidgoyal.net/kitty/keyboard-protocol/
- https://codeberg.org/dnkl/foot/src/commit/e891abdd6a6652bd46b28c1988700a7f30931210/kitty-keymap.h
- https://github.com/kovidgoyal/kitty/blob/d31459b0926f2afddc317d76314e4afd0d07d473/kitty/key_encoding.c#L193

fixes: #15868
closes: #15881

Signed-off-by: Christian Fillion <contact@cfillion.ca>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/edit.c
src/testdir/test_termcodes.vim
src/version.c

index e1f30c7c2e36c5ac9208ceb44ac038a88bf29d5e..f4c5edfc43a858c9a3fdc22165f47f8f69ec2826 100644 (file)
@@ -1625,7 +1625,8 @@ decodeModifyOtherKeys(int c)
     if (typebuf.tb_len >= 4 && (c == CSI || (c == ESC && *p == '[')))
     {
        idx = (*p == '[');
-       if (p[idx] == '2' && p[idx + 1] == '7' && p[idx + 2] == ';')
+       if (p[idx] == '2' && p[idx + 1] == '7' && p[idx + 2] == ';' &&
+               kitty_protocol_state != KKPS_ENABLED)
        {
            form = 1;
            idx += 3;
@@ -1640,9 +1641,10 @@ decodeModifyOtherKeys(int c)
                break;
            ++idx;
        }
+       int kitty_no_mods = argidx == 0 && kitty_protocol_state == KKPS_ENABLED;
        if (idx < typebuf.tb_len
                && p[idx] == (form == 1 ? '~' : 'u')
-               && argidx == 1)
+               && (argidx == 1 || kitty_no_mods))
        {
            // Match, consume the code.
            typebuf.tb_off += idx + 1;
@@ -1652,7 +1654,7 @@ decodeModifyOtherKeys(int c)
                typebuf_was_filled = FALSE;
 #endif
 
-           mod_mask = decode_modifiers(arg[!form]);
+           mod_mask = kitty_no_mods ? 0 : decode_modifiers(arg[!form]);
            c = merge_modifyOtherKeys(arg[form], &mod_mask);
        }
     }
index 507753c21a7736ef550ac3df91502d66eddbd2a2..2b44b1553519de03c1d9320b3d7fba5683d857bf 100644 (file)
@@ -2001,6 +2001,12 @@ func Test_xx08_kitty_response()
         \ kitty: 'y',
         \ }, terminalprops())
 
+  call feedkeys("\<Esc>[?1u") " simulate the kitty keyboard protocol is enabled
+  call feedkeys(':' .. GetEscCodeCSIu('V', '5') .. GetEscCodeCSIuWithoutModifier("\<Esc>") .. "\<C-B>\"\<CR>", 'Lx!')
+  call assert_equal("\"\<Esc>", @:)
+  call feedkeys(':' .. GetEscCodeCSIu('V', '5') .. GetEscCodeCSIu("\<Esc>", '129') .. "\<C-B>\"\<CR>", 'Lx!')
+  call assert_equal("\"\<Esc>", @:)
+
   set t_RV=
   call test_override('term_props', 0)
 endfunc
index b8852e39b4be4efdbf3bf208d1606a2ba7ef311a..b3cc9ce55b041fbe5cd39c016045578498f7e39a 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    788,
 /**/
     787,
 /**/