modifiers |= MOD_MASK_CTRL;
if (code & 8)
modifiers |= MOD_MASK_META;
+ // Any further modifiers are silently dropped.
+
return modifiers;
}
// Key with modifier:
// {lead}27;{modifier};{key}~
// {lead}{key};{modifier}u
- // Only handles four modifiers, this won't work if the modifier value is
- // more than 16.
- else if (((arg[0] == 27 && argc == 3 && trail == '~')
+ // Even though we only handle four modifiers and the {modifier} value
+ // should be 16 or lower, we accept all modifier values to avoid the raw
+ // sequence to be passed through.
+ else if ((arg[0] == 27 && argc == 3 && trail == '~')
|| (argc == 2 && trail == 'u'))
- && arg[1] <= 16)
{
return len + handle_key_with_modifier(arg, trail,
- csi_len, offset, buf, bufsize, buflen);
+ csi_len, offset, buf, bufsize, buflen);
}
// Key without modifier (Kitty sends this for Esc):
call RunTest_mapping_works_with_mods(function('GetEscCodeCSIu'), 'C-S-A', 8)
endfunc
+func Test_mapping_works_with_unknown_modifiers()
+ new
+ set timeoutlen=10
+
+ for Func in [function('GetEscCodeCSI27'), function('GetEscCodeCSIu')]
+ call RunTest_mapping_mods('<C-z>', 'z', Func, 5)
+ " Add 16, 32, 64 or 128 for modifiers we currently don't support.
+ call RunTest_mapping_mods('<C-z>', 'z', Func, 5 + 16)
+ call RunTest_mapping_mods('<C-z>', 'z', Func, 5 + 32)
+ call RunTest_mapping_mods('<C-z>', 'z', Func, 5 + 64)
+ call RunTest_mapping_mods('<C-z>', 'z', Func, 5 + 128)
+
+ call RunTest_mapping_mods('<S-X>', 'X', Func, 2)
+ " Add 16, 32, 64 or 128 for modifiers we currently don't support.
+ call RunTest_mapping_mods('<S-X>', 'X', Func, 2 + 16)
+ call RunTest_mapping_mods('<S-X>', 'X', Func, 2 + 32)
+ call RunTest_mapping_mods('<S-X>', 'X', Func, 2 + 64)
+ call RunTest_mapping_mods('<S-X>', 'X', Func, 2 + 128)
+ endfor
+
+ bwipe!
+ set timeoutlen&
+endfunc
+
func Test_insert_literal()
set timeoutlen=10