diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-01-23 18:55:11 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-23 18:55:11 +0800 |
commit | 0371d0f7afa5e01dd2ac8bbd3abcf0f7454872b3 (patch) | |
tree | a12edba6f135a7b2ca9fa49f9c95f09d1a56f12e /src/nvim/buffer.c | |
parent | d58bf4ff307060829ba01f41dca52416105243d3 (diff) | |
download | rneovim-0371d0f7afa5e01dd2ac8bbd3abcf0f7454872b3.tar.gz rneovim-0371d0f7afa5e01dd2ac8bbd3abcf0f7454872b3.tar.bz2 rneovim-0371d0f7afa5e01dd2ac8bbd3abcf0f7454872b3.zip |
refactor(win_close): remove "force", don't pass on "free_buf" (#21921)
Problem:
The "force" flag of win_close() complicates the code and adds edge cases
where it is not clear what the correct behavior should be.
The "free_buf" flag of win_close() is passed on to float windows when
closing the last window of a tabpage, which doesn't make much sense.
Solution:
Remove the "force" flag and always close float windows as if :close! is
used when closing the last window of a tabpage, and set the "free_buf"
flag for a float window based on whether its buffer can be freed.
As 'hidden' is on by default, this change shouldn't affect many people.
Diffstat (limited to 'src/nvim/buffer.c')
-rw-r--r-- | src/nvim/buffer.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 5dcb10751f..332c6cadb8 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -933,7 +933,7 @@ void goto_buffer(exarg_T *eap, int start, int dir, int count) enter_cleanup(&cs); // Quitting means closing the split window, nothing else. - win_close(curwin, true, false); + win_close(curwin, true); swap_exists_action = SEA_NONE; swap_exists_did_quit = true; @@ -1335,7 +1335,7 @@ int do_buffer(int action, int start, int dir, int count, int forceit) while (buf == curbuf && !(curwin->w_closing || curwin->w_buffer->b_locked > 0) && (is_aucmd_win(lastwin) || !last_window(curwin))) { - if (win_close(curwin, false, false) == FAIL) { + if (win_close(curwin, false) == FAIL) { break; } } @@ -3620,7 +3620,7 @@ void ex_buffer_all(exarg_T *eap) && !ONE_WINDOW && !(wp->w_closing || wp->w_buffer->b_locked > 0)) { - win_close(wp, false, false); + win_close(wp, false); wpnext = firstwin; // just in case an autocommand does // something strange with windows tpnext = first_tabpage; // start all over... @@ -3700,7 +3700,7 @@ void ex_buffer_all(exarg_T *eap) enter_cleanup(&cs); // User selected Quit at ATTENTION prompt; close this window. - win_close(curwin, true, false); + win_close(curwin, true); open_wins--; swap_exists_action = SEA_NONE; swap_exists_did_quit = true; @@ -3740,7 +3740,7 @@ void ex_buffer_all(exarg_T *eap) // BufWrite Autocommands made the window invalid, start over wp = lastwin; } else if (r) { - win_close(wp, !buf_hide(wp->w_buffer), false); + win_close(wp, !buf_hide(wp->w_buffer)); open_wins--; wp = lastwin; } else { |