neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 6dd7fcaafdc5d80948e1c4b05b19584de16528d6
parent 3f0adf90debb35b5a937480151a659d654106ff6
Author: bfredl <bjorn.linse@gmail.com>
Date:   Thu,  9 Jan 2025 13:35:25 +0100

Merge pull request #31898 from bfredl/termbomb

fix(terminal): don't crash on unprintable chars
Diffstat:
Msrc/nvim/vterm/screen.c | 2+-
Mtest/functional/terminal/buffer_spec.lua | 13+++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/nvim/vterm/screen.c b/src/nvim/vterm/screen.c @@ -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; diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua @@ -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, {})