mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
fix(keycodes): recognize <t_xx> as a key (#24700)
Problem: The result of keytrans() sometimes can't be translated back. Solution: Recognize <t_xx> as a key.
This commit is contained in:
parent
cbf54ec2a5
commit
017ff93b02
@ -825,6 +825,10 @@ int find_special_key_in_table(int c)
|
|||||||
int get_special_key_code(const char *name)
|
int get_special_key_code(const char *name)
|
||||||
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
|
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
|
||||||
{
|
{
|
||||||
|
if (name[0] == 't' && name[1] == '_' && name[2] != NUL && name[3] != NUL) {
|
||||||
|
return TERMCAP2KEY((uint8_t)name[2], (uint8_t)name[3]);
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; key_names_table[i].name != NULL; i++) {
|
for (int i = 0; key_names_table[i].name != NULL; i++) {
|
||||||
const char *const table_name = key_names_table[i].name;
|
const char *const table_name = key_names_table[i].name;
|
||||||
int j;
|
int j;
|
||||||
|
@ -1957,6 +1957,12 @@ describe('API', function()
|
|||||||
-- value.
|
-- value.
|
||||||
eq('', meths.replace_termcodes('', true, true, true))
|
eq('', meths.replace_termcodes('', true, true, true))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- Not exactly the case, as nvim_replace_termcodes() escapes K_SPECIAL in Unicode
|
||||||
|
it('translates the result of keytrans() on string with 0x80 byte back', function()
|
||||||
|
local s = 'ff\128\253\097tt'
|
||||||
|
eq(s, meths.replace_termcodes(funcs.keytrans(s), true, true, true))
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('nvim_feedkeys', function()
|
describe('nvim_feedkeys', function()
|
||||||
|
Loading…
Reference in New Issue
Block a user