mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +00:00
fix(terminal): avoid reading over the end of cell.chars (#19580)
This commit is contained in:
@ -1384,7 +1384,7 @@ static void fetch_row(Terminal *term, int row, int end_col)
|
||||
fetch_cell(term, row, col, &cell);
|
||||
if (cell.chars[0]) {
|
||||
int cell_len = 0;
|
||||
for (int i = 0; cell.chars[i]; i++) {
|
||||
for (int i = 0; i < VTERM_MAX_CHARS_PER_CELL && cell.chars[i]; i++) {
|
||||
cell_len += utf_char2bytes((int)cell.chars[i], ptr + cell_len);
|
||||
}
|
||||
ptr += cell_len;
|
||||
|
@ -5,6 +5,8 @@ local feed, clear, nvim = helpers.feed, helpers.clear, helpers.nvim
|
||||
local poke_eventloop = helpers.poke_eventloop
|
||||
local eval, feed_command, source = helpers.eval, helpers.feed_command, helpers.source
|
||||
local eq, neq = helpers.eq, helpers.neq
|
||||
local meths = helpers.meths
|
||||
local retry = helpers.retry
|
||||
local write_file = helpers.write_file
|
||||
local command = helpers.command
|
||||
local exc_exec = helpers.exc_exec
|
||||
@ -364,3 +366,11 @@ describe('on_lines does not emit out-of-bounds line indexes when', function()
|
||||
eq('', exec_lua([[return _G.cb_error]]))
|
||||
end)
|
||||
end)
|
||||
|
||||
it('terminal truncates number of composing characters to 5', function()
|
||||
clear()
|
||||
local chan = meths.open_term(0, {})
|
||||
local composing = ('a̳'):sub(2)
|
||||
meths.chan_send(chan, 'a' .. composing:rep(8))
|
||||
retry(nil, nil, function() eq('a' .. composing:rep(5), meths.get_current_line()) end)
|
||||
end)
|
||||
|
Reference in New Issue
Block a user