Merge pull request #31898 from bfredl/termbomb

fix(terminal): don't crash on unprintable chars
This commit is contained in:
bfredl 2025-01-09 13:35:25 +01:00 committed by GitHub
commit 6dd7fcaafd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 1 deletions

View File

@ -909,7 +909,7 @@ int vterm_screen_get_cell(const VTermScreen *screen, VTermPos pos, VTermScreenCe
return 0;
}
cell->schar = intcell->schar;
cell->schar = (intcell->schar == (uint32_t)-1) ? 0 : intcell->schar;
cell->attrs.bold = intcell->pen.bold;
cell->attrs.underline = intcell->pen.underline;

View File

@ -435,6 +435,19 @@ describe(':terminal buffer', function()
]])
end)
it('handles unprintable chars', function()
local screen = Screen.new(50, 7)
feed 'i'
local chan = api.nvim_open_term(0, {})
api.nvim_chan_send(chan, '\239\187\191') -- '\xef\xbb\xbf'
screen:expect([[
{18:<feff>}^ |
|*5
{5:-- TERMINAL --} |
]])
eq('\239\187\191', api.nvim_get_current_line())
end)
it("handles bell respecting 'belloff' and 'visualbell'", function()
local screen = Screen.new(50, 7)
local chan = api.nvim_open_term(0, {})