patch 9.1.0572: cannot specify tab page closing behaviour
Problem: cannot specify tab page closing behaviour
(Gianluca Pacchiella)
Solution: Add the 'tabclose' option (LemonBoy).
fixes: #5967
closes: #15204
Signed-off-by: LemonBoy <thatlemon@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/window.c b/src/window.c
index 7322905..c87cce0 100644
--- a/src/window.c
+++ b/src/window.c
@@ -3782,15 +3782,23 @@
static tabpage_T *
alt_tabpage(void)
{
- tabpage_T *tp;
+ tabpage_T *tp = NULL;
+ int forward;
- // 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.
- for (tp = first_tabpage; tp->tp_next != curtab; tp = tp->tp_next)
- ;
+ // Use the previous tab page, if possible.
+ forward = curtab->tp_next != NULL &&
+ ((tcl_flags & TCL_LEFT) == 0 || curtab == first_tabpage);
+
+ if (forward)
+ tp = curtab->tp_next;
+ else
+ for (tp = first_tabpage; tp->tp_next != curtab; tp = tp->tp_next)
+ ;
+
return tp;
}