mirror of
https://github.com/neovim/neovim.git
synced 2026-02-21 18:01:17 +10:00
fix(terminal): crash when TermClose switches back to terminal buffer
Problem: Crash when deleting terminal buffer and TermClose switches
back to the terminal buffer.
Solution: Set b_locked_split.
Co-authored-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
(cherry picked from commit ad85871ca1)
This commit is contained in:
committed by
github-actions[bot]
parent
2cc78732fc
commit
ea871923eb
@@ -660,7 +660,10 @@ bool close_buffer(win_T *win, buf_T *buf, int action, bool abort_if_last, bool i
|
|||||||
buf->b_nwindows = nwindows;
|
buf->b_nwindows = nwindows;
|
||||||
|
|
||||||
if (buf->terminal) {
|
if (buf->terminal) {
|
||||||
|
buf->b_locked_split++;
|
||||||
buf_close_terminal(buf);
|
buf_close_terminal(buf);
|
||||||
|
buf->b_locked_split--;
|
||||||
|
|
||||||
// Must check this before calling buf_freeall(), otherwise is_curbuf will be true
|
// Must check this before calling buf_freeall(), otherwise is_curbuf will be true
|
||||||
// in buf_freeall() but still false here, leading to a 0-line buffer.
|
// in buf_freeall() but still false here, leading to a 0-line buffer.
|
||||||
if (buf == curbuf && !is_curbuf) {
|
if (buf == curbuf && !is_curbuf) {
|
||||||
|
|||||||
@@ -57,6 +57,17 @@ describe('autocmd TermClose', function()
|
|||||||
assert_alive()
|
assert_alive()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('TermClose switching back to terminal buffer', function()
|
||||||
|
local buf = api.nvim_get_current_buf()
|
||||||
|
api.nvim_open_term(buf, {})
|
||||||
|
command(('autocmd TermClose * buffer %d | new'):format(buf))
|
||||||
|
eq(
|
||||||
|
'TermClose Autocommands for "*": Vim(buffer):E1546: Cannot switch to a closing buffer',
|
||||||
|
pcall_err(command, 'bwipe!')
|
||||||
|
)
|
||||||
|
assert_alive()
|
||||||
|
end)
|
||||||
|
|
||||||
it('triggers when fast-exiting terminal job stops', function()
|
it('triggers when fast-exiting terminal job stops', function()
|
||||||
command('autocmd TermClose * let g:test_termclose = 23')
|
command('autocmd TermClose * let g:test_termclose = 23')
|
||||||
command('terminal')
|
command('terminal')
|
||||||
|
|||||||
Reference in New Issue
Block a user