aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/window.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-07-13 08:56:58 +0800
committerGitHub <noreply@github.com>2024-07-13 08:56:58 +0800
commitb1aa8f5eb8a5407e869335e9987b73f8515c37e5 (patch)
tree11d8e4909a8b191fbe627354fe68972102d6e467 /src/nvim/window.c
parent10256bb760fcab0dc25f7eb5b0b45966cb771939 (diff)
downloadrneovim-b1aa8f5eb8a5407e869335e9987b73f8515c37e5.tar.gz
rneovim-b1aa8f5eb8a5407e869335e9987b73f8515c37e5.tar.bz2
rneovim-b1aa8f5eb8a5407e869335e9987b73f8515c37e5.zip
vim-patch:9.1.0572: cannot specify tab page closing behaviour (#29682)
Problem: cannot specify tab page closing behaviour (Gianluca Pacchiella) Solution: Add the 'tabclose' option (LemonBoy). fixes: vim/vim#5967 closes: vim/vim#15204 https://github.com/vim/vim/commit/5247b0b92e191a046b034171a3b34031e317735f Co-authored-by: LemonBoy <thatlemon@gmail.com>
Diffstat (limited to 'src/nvim/window.c')
-rw-r--r--src/nvim/window.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 9203dd1bdb..132bf9ee60 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -3456,14 +3456,22 @@ static frame_T *win_altframe(win_T *win, tabpage_T *tp)
// Return the tabpage that will be used if the current one is closed.
static tabpage_T *alt_tabpage(void)
{
- // Use the next tab page if possible.
- if (curtab->tp_next != NULL) {
- return curtab->tp_next;
+ // Use the last accessed tab page, if possible.
+ if ((tcl_flags & TCL_USELAST) && valid_tabpage(lastused_tabpage)) {
+ return lastused_tabpage;
}
- // Find the last but one tab page.
+ // Use the previous tab page, if possible.
+ bool forward = curtab->tp_next != NULL
+ && ((tcl_flags & TCL_LEFT) == 0 || curtab == first_tabpage);
+
tabpage_T *tp;
- for (tp = first_tabpage; tp->tp_next != curtab; tp = tp->tp_next) {}
+ if (forward) {
+ tp = curtab->tp_next;
+ } else {
+ for (tp = first_tabpage; tp->tp_next != curtab; tp = tp->tp_next) {}
+ }
+
return tp;
}