mirror of
https://github.com/neovim/neovim.git
synced 2026-04-01 05:12:02 +00:00
fix(terminal): crash after deleting buffer lines (#37921)
Problem: Terminal crashes after deleting buffer lines. Solution: Don't insert lines above lines 0.
This commit is contained in:
@@ -2470,6 +2470,8 @@ static void refresh_scrollback(Terminal *term, buf_T *buf)
|
||||
deleted--;
|
||||
}
|
||||
|
||||
// Clamp old_height in case buffer lines have been deleted by the user.
|
||||
old_height = MIN(old_height, buf->b_ml.ml_line_count);
|
||||
while (term->sb_pending > 0) {
|
||||
// This means that either the window height has decreased or the screen
|
||||
// became full and libvterm had to push all rows up. Convert the first
|
||||
|
||||
@@ -1101,6 +1101,31 @@ describe('pending scrollback line handling', function()
|
||||
]]
|
||||
assert_alive()
|
||||
end)
|
||||
|
||||
it('does not crash after deleting buffer lines', function()
|
||||
local buf = api.nvim_get_current_buf()
|
||||
local chan = api.nvim_open_term(buf, {})
|
||||
api.nvim_chan_send(chan, ('a\n'):rep(11) .. 'a')
|
||||
screen:expect([[
|
||||
^a |
|
||||
a |*5
|
||||
|
|
||||
]])
|
||||
api.nvim_set_option_value('modifiable', true, { buf = buf })
|
||||
api.nvim_buf_set_lines(buf, 0, -1, true, {})
|
||||
screen:expect([[
|
||||
^ |
|
||||
{1:~ }|*5
|
||||
|
|
||||
]])
|
||||
api.nvim_chan_send(chan, ('\nb'):rep(11) .. '\n')
|
||||
screen:expect([[
|
||||
b |*5
|
||||
^ |
|
||||
|
|
||||
]])
|
||||
assert_alive()
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('scrollback is correct', function()
|
||||
|
||||
Reference in New Issue
Block a user