mirror of
https://github.com/neovim/neovim.git
synced 2026-06-15 16:23:48 +00:00
fix(float): don't unload 'hidden' float buffer with :close! (#39304)
Problem: When closing floating windows to close a tabpage, if the current
buffer will unload, buffers contained in those floating windows
will too (unexpectedly).
Solution: Don't pass along "free_buf" argument; check 'bufhidden' for
the buffer in the to be closed float.
(cherry picked from commit 5b0ad4a060)
Co-authored-by: luukvbaal <luukvbaal@gmail.com>
This commit is contained in:
committed by
GitHub
parent
eebd98fd99
commit
6ae6cf5d61
@@ -2853,7 +2853,7 @@ int win_close(win_T *win, bool free_buf, bool force)
|
||||
// close the last window until the there are no floating windows
|
||||
while (lastwin->w_floating) {
|
||||
// `force` flag isn't actually used when closing a floating window.
|
||||
if (win_close(lastwin, free_buf, true) == FAIL) {
|
||||
if (win_close(lastwin, !buf_hide(lastwin->w_buffer), true) == FAIL) {
|
||||
// If closing the window fails give up, to avoid looping forever.
|
||||
return FAIL;
|
||||
}
|
||||
@@ -3216,7 +3216,7 @@ bool win_close_othertab(win_T *win, int free_buf, tabpage_T *tp, bool force)
|
||||
// close the last window until the there are no floating windows
|
||||
while (tp->tp_lastwin->w_floating) {
|
||||
// `force` flag isn't actually used when closing a floating window.
|
||||
if (!win_close_othertab(tp->tp_lastwin, free_buf, tp, true)) {
|
||||
if (!win_close_othertab(tp->tp_lastwin, !buf_hide(tp->tp_lastwin->w_buffer), tp, true)) {
|
||||
// If closing the window fails give up, to avoid looping forever.
|
||||
goto leave_open;
|
||||
}
|
||||
|
||||
@@ -1072,6 +1072,15 @@ describe('float window', function()
|
||||
command('close')
|
||||
assert_alive()
|
||||
end)
|
||||
|
||||
it('does not unload bufhidden=hide buffer', function()
|
||||
local buf = api.nvim_create_buf(false, true)
|
||||
command('set nohidden')
|
||||
api.nvim_open_tabpage(0, true, {})
|
||||
api.nvim_open_win(buf, false, { relative = 'editor', width = 1, height = 1, row = 0, col = 0 })
|
||||
command('close!')
|
||||
eq(true, api.nvim_buf_is_loaded(buf))
|
||||
end)
|
||||
end)
|
||||
|
||||
it('placed relative to tabline and laststatus', function()
|
||||
|
||||
Reference in New Issue
Block a user