Skip to content

Commit

Permalink
fix(window): close floats first when closing buffer in other tab (neo…
Browse files Browse the repository at this point in the history
  • Loading branch information
zeertzjq authored and lvimuser committed Oct 6, 2022
1 parent ee9b653 commit 350c8e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/nvim/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -2464,7 +2464,8 @@ void close_windows(buf_T *buf, bool keep_curwin)
for (tp = first_tabpage; tp != NULL; tp = nexttp) {
nexttp = tp->tp_next;
if (tp != curtab) {
FOR_ALL_WINDOWS_IN_TAB(wp, tp) {
// Start from tp_lastwin to close floating windows with the same buffer first.
for (win_T *wp = tp->tp_lastwin; wp != NULL; wp = wp->w_prev) {
if (wp->w_buffer == buf
&& !(wp->w_closing || wp->w_buffer->b_locked > 0)) {
win_close_othertab(wp, false, tp);
Expand Down
5 changes: 5 additions & 0 deletions test/functional/ui/float_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,11 @@ describe('float window', function()
meths.buf_delete(old_buf, {force = true})
eq(old_win, curwin().id)
end)
it('if called from non-floating window in another tabpage', function()
command('tab split')
eq(3, #meths.list_tabpages())
meths.buf_delete(old_buf, {force = true})
end)
it('if called from floating window with the same buffer', function()
meths.set_current_win(same_buf_float)
command('autocmd WinLeave * let g:win_leave = nvim_get_current_win()')
Expand Down

0 comments on commit 350c8e0

Please sign in to comment.