mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 09:26:30 +00:00
fix(float): don't always switch window when deleting last listed buffer (#17836)
This commit is contained in:
@@ -1043,8 +1043,20 @@ static int empty_curbuf(int close_others, int forceit, int action)
|
||||
|
||||
if (close_others) {
|
||||
if (curwin->w_floating) {
|
||||
// Last window must be non-floating.
|
||||
curwin = firstwin;
|
||||
bool can_close_all_others = false;
|
||||
for (win_T *wp = firstwin; !wp->w_floating; wp = wp->w_next) {
|
||||
if (wp->w_buffer != curbuf) {
|
||||
// Found another non-floating window with a different (probably unlisted) buffer.
|
||||
// Closing all other windows with the this buffer is fine in this case.
|
||||
can_close_all_others = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!can_close_all_others) {
|
||||
// Closing all other windows with this buffer will close all non-floating windows.
|
||||
// Move to a non-floating window then.
|
||||
curwin = firstwin;
|
||||
}
|
||||
}
|
||||
// Close any other windows on this buffer, then make it empty.
|
||||
close_windows(buf, true);
|
||||
|
@@ -2350,9 +2350,9 @@ void entering_window(win_T *const win)
|
||||
}
|
||||
}
|
||||
|
||||
/// Closes all windows for buffer `buf` until there is only one non-floating window.
|
||||
/// Closes all windows for buffer `buf` unless there is only one non-floating window.
|
||||
///
|
||||
/// @param keep_curwin don't close `curwin`, but caller must ensure `curwin` is non-floating.
|
||||
/// @param keep_curwin don't close `curwin`
|
||||
void close_windows(buf_T *buf, bool keep_curwin)
|
||||
{
|
||||
tabpage_T *tp, *nexttp;
|
||||
@@ -2360,8 +2360,6 @@ void close_windows(buf_T *buf, bool keep_curwin)
|
||||
|
||||
++RedrawingDisabled;
|
||||
|
||||
assert(!keep_curwin || !curwin->w_floating);
|
||||
|
||||
// Start from lastwin to close floating windows with the same buffer first.
|
||||
// When the autocommand window is involved win_close() may need to print an error message.
|
||||
for (win_T *wp = lastwin; wp != NULL && (lastwin == aucmd_win || !one_window(wp));) {
|
||||
|
Reference in New Issue
Block a user