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/ex_docmd.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/ex_docmd.c')
-rw-r--r-- | src/nvim/ex_docmd.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index a24e8458a6..f7f38e225c 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -4553,7 +4553,7 @@ static void ex_quit(exarg_T *eap) } not_exiting(); // close window; may free buffer - win_close(wp, !buf_hide(wp->w_buffer) || eap->forceit, eap->forceit); + win_close(wp, !buf_hide(wp->w_buffer) || eap->forceit); } } @@ -4663,7 +4663,7 @@ void ex_win_close(int forceit, win_T *win, tabpage_T *tp) // free buffer when not hiding it or when it's a scratch buffer if (tp == NULL) { - win_close(win, !need_hide && !buf_hide(buf), forceit); + win_close(win, !need_hide && !buf_hide(buf)); } else { win_close_othertab(win, !need_hide && !buf_hide(buf), tp); } @@ -4811,7 +4811,7 @@ static void ex_hide(exarg_T *eap) } if (eap->addr_count == 0) { - win_close(curwin, false, eap->forceit); // don't free buffer + win_close(curwin, false); // don't free buffer } else { int winnr = 0; win_T *win = NULL; @@ -4826,7 +4826,7 @@ static void ex_hide(exarg_T *eap) if (win == NULL) { win = lastwin; } - win_close(win, false, eap->forceit); + win_close(win, false); } } @@ -4883,7 +4883,7 @@ static void ex_exit(exarg_T *eap) } not_exiting(); // Quit current window, may free the buffer. - win_close(curwin, !buf_hide(curwin->w_buffer), eap->forceit); + win_close(curwin, !buf_hide(curwin->w_buffer)); } } @@ -5282,7 +5282,7 @@ void do_exedit(exarg_T *eap, win_T *old_curwin) // Reset the error/interrupt/exception state here so that // aborting() returns false when closing a window. enter_cleanup(&cs); - win_close(curwin, !need_hide && !buf_hide(curbuf), false); + win_close(curwin, !need_hide && !buf_hide(curbuf)); // Restore the error/interrupt/exception state if not // discarded by a new aborting error, interrupt, or |