mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 11:15:14 -07:00
input: Escape utf8 sequences that contain CSI/K_SPECIAL
This commit is contained in:
parent
25ceadab37
commit
e7c945ab59
@ -148,7 +148,12 @@ size_t input_enqueue(String keys)
|
||||
uint8_t buf[6] = {0};
|
||||
unsigned int new_size = trans_special((uint8_t **)&ptr, buf, true);
|
||||
|
||||
if (!new_size) {
|
||||
if (new_size) {
|
||||
new_size = handle_mouse_event(&ptr, buf, new_size);
|
||||
rbuffer_write(input_buffer, (char *)buf, new_size);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (*ptr == '<') {
|
||||
// Invalid key sequence, skip until the next '>' or until *end
|
||||
do {
|
||||
@ -157,13 +162,20 @@ size_t input_enqueue(String keys)
|
||||
ptr++;
|
||||
continue;
|
||||
}
|
||||
// copy the character unmodified
|
||||
*buf = (uint8_t)*ptr++;
|
||||
new_size = 1;
|
||||
}
|
||||
|
||||
new_size = handle_mouse_event(&ptr, buf, new_size);
|
||||
rbuffer_write(input_buffer, (char *)buf, new_size);
|
||||
// copy the character, escaping CSI and K_SPECIAL
|
||||
if ((uint8_t)*ptr == CSI) {
|
||||
rbuffer_write(input_buffer, (char *)&(uint8_t){K_SPECIAL}, 1);
|
||||
rbuffer_write(input_buffer, (char *)&(uint8_t){KS_EXTRA}, 1);
|
||||
rbuffer_write(input_buffer, (char *)&(uint8_t){KE_CSI}, 1);
|
||||
} else if ((uint8_t)*ptr == K_SPECIAL) {
|
||||
rbuffer_write(input_buffer, (char *)&(uint8_t){K_SPECIAL}, 1);
|
||||
rbuffer_write(input_buffer, (char *)&(uint8_t){KS_SPECIAL}, 1);
|
||||
rbuffer_write(input_buffer, (char *)&(uint8_t){KE_FILLER}, 1);
|
||||
} else {
|
||||
rbuffer_write(input_buffer, ptr, 1);
|
||||
}
|
||||
ptr++;
|
||||
}
|
||||
|
||||
size_t rv = (size_t)(ptr - keys.data);
|
||||
|
@ -16,7 +16,7 @@ describe('mapping', function()
|
||||
|
||||
-- Abbreviations with р (0x80) should work.
|
||||
execute('inoreab чкпр vim')
|
||||
feed('GAчкпр <cr><esc>')
|
||||
feed('GAчкпр <esc>')
|
||||
|
||||
-- langmap should not get remapped in insert mode.
|
||||
execute('inoremap { FAIL_ilangmap')
|
||||
@ -27,6 +27,7 @@ describe('mapping', function()
|
||||
execute('inoremap <expr> { "FAIL_iexplangmap"')
|
||||
feed('o+<esc>')
|
||||
|
||||
|
||||
-- Assert buffer contents.
|
||||
expect([[
|
||||
test starts here:
|
||||
|
@ -1,6 +1,7 @@
|
||||
local helpers = require('test.functional.helpers')
|
||||
local clear, execute, nvim = helpers.clear, helpers.execute, helpers.nvim
|
||||
local feed, next_message, eq = helpers.feed, helpers.next_message, helpers.eq
|
||||
local expect = helpers.expect
|
||||
|
||||
describe('mappings', function()
|
||||
local cid
|
||||
@ -38,3 +39,10 @@ describe('mappings', function()
|
||||
check_mapping('<a-s-c-up>', '<c-s-a-up>')
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('input utf sequences that contain CSI/K_SPECIAL', function()
|
||||
it('ok', function()
|
||||
feed('i…<esc>')
|
||||
expect('…')
|
||||
end)
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user