aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/buffer.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-03-24 11:56:22 +0800
committerGitHub <noreply@github.com>2022-03-24 11:56:22 +0800
commitff82b2785f161fc14ff6bd8eae497f37ecd14564 (patch)
tree485a46d944ffa2a729806be74ea28617cc72887e /src/nvim/buffer.c
parent2e3611784011a82be239341c00d435cb7cf7b711 (diff)
downloadrneovim-ff82b2785f161fc14ff6bd8eae497f37ecd14564.tar.gz
rneovim-ff82b2785f161fc14ff6bd8eae497f37ecd14564.tar.bz2
rneovim-ff82b2785f161fc14ff6bd8eae497f37ecd14564.zip
fix(float): don't always switch window when deleting last listed buffer (#17836)
Diffstat (limited to 'src/nvim/buffer.c')
-rw-r--r--src/nvim/buffer.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 1fe80dc24c..7fc880fb41 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -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);