mirror of
https://github.com/neovim/neovim.git
synced 2026-07-16 06:10:39 +00:00
fix(excmd): :bufdelete may fail from floating window #39800
Problem: with a float focused and the target buf only shown in the last non-float window, do_buffer_ext goes down the buf != curbuf path. close_windows can't touch the last non-float, b_nwindows stays > 0, close_buffer is skipped, returns OK silently. Solution: if a non-float still holds buf after close_windows, jump into it and recurse. Then buf == curbuf and the existing replacement path takes over.
This commit is contained in:
@@ -1462,6 +1462,14 @@ static int do_buffer_ext(int action, int start, int dir, int count, int flags)
|
||||
}
|
||||
|
||||
close_windows(buf, false);
|
||||
// close_windows keeps the last non-float window. If it still
|
||||
// shows buf, jump there and retry so curbuf gets replaced.
|
||||
if (bufref_valid(&bufref) && buf->b_nwindows > 0) {
|
||||
win_T *holder = buf_jump_open_win(buf);
|
||||
if (holder != NULL && !holder->w_floating) {
|
||||
return do_buffer_ext(action, start, dir, count, flags);
|
||||
}
|
||||
}
|
||||
|
||||
if (buf != curbuf && bufref_valid(&bufref) && buf->b_nwindows <= 0) {
|
||||
close_buffer(NULL, buf, action, false, false, false);
|
||||
|
||||
@@ -761,8 +761,7 @@ describe('float window', function()
|
||||
eq(old_win, eval('g:win_enter'))
|
||||
eq(old_win, curwin())
|
||||
end)
|
||||
-- TODO: this case is too hard to deal with
|
||||
pending('if called from floating window with another buffer', function()
|
||||
it('if called from floating window with another buffer', function()
|
||||
api.nvim_set_current_win(other_buf_float)
|
||||
api.nvim_buf_delete(old_buf, { force = true })
|
||||
end)
|
||||
@@ -794,8 +793,7 @@ describe('float window', function()
|
||||
eq(old_win, eval('g:win_enter'))
|
||||
eq(old_win, curwin())
|
||||
end)
|
||||
-- TODO: this case is too hard to deal with
|
||||
pending('if called from floating window with an unlisted buffer', function()
|
||||
it('if called from floating window with an unlisted buffer', function()
|
||||
api.nvim_set_current_win(unlisted_buf_float)
|
||||
api.nvim_buf_delete(old_buf, { force = true })
|
||||
end)
|
||||
@@ -963,8 +961,7 @@ describe('float window', function()
|
||||
api.nvim_set_current_win(same_buf_float)
|
||||
api.nvim_buf_delete(old_buf, { force = false })
|
||||
end)
|
||||
-- TODO: this case is too hard to deal with
|
||||
pending('if called from floating window with another buffer', function()
|
||||
it('if called from floating window with another buffer', function()
|
||||
api.nvim_set_current_win(other_buf_float)
|
||||
api.nvim_buf_delete(old_buf, { force = false })
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user