[vim/vim] tabpanel: scrollbar completion, follow curtab, right-edge layout (PR #20052)

2 views
Skip to first unread message

h_east

unread,
Apr 23, 2026, 7:51:08 PM (17 hours ago) Apr 23
to vim/vim, Subscribed

Problem: Several issues around the tabpanel scrollbar:
1. :set tabpanelopt= completion did not offer "scroll" and
"scrollbar".
2. gt/gT and other tab switches did not update the scrollbar
thumb; the current tab could move outside the visible
panel range without the view following.
3. When tpl_scroll_offset was at its maximum, the thumb's
bottom did not reach the last screen row due to integer
truncation in thumb_top (e.g. 31 tabs on 24 rows + :tablast
left a one-row gap).
4. For align:right the scrollbar was drawn on the panel's
left edge (adjacent to the buffer area), which breaks the
common convention that a vertical scrollbar sits on the
right.
Solution: - Add "scroll" and "scrollbar" to the 'tabpanelopt' expansion
list. Cover the completion in test_options.vim and extend
util/gen_opt_test.vim with the new valid/invalid values;
drop the now-redundant acceptance test from
test_tabpanel.vim.
- In draw_tabpanel(), remember the last-drawn curtab and,
when it changes, adjust tpl_scroll_offset so curtab_row
falls inside [offset, offset + Rows). Mouse wheel and
drag leave curtab unchanged, so the user's chosen offset
is preserved.
- In draw_tabpanel_scrollbar(), compute thumb_top as
(Rows - thumb_height) * tpl_scroll_offset
/ (tpl_total_rows - Rows), mirroring the mapping already
used by tabpanel_drag_scrollbar(). This guarantees the
thumb's bottom reaches the last row at the maximum offset.
- In draw_tabpanel(), place the scrollbar at the tabpanel's
right edge for both align:left and align:right (previously
align:right put it on the panel's left edge next to the
vertical separator). For align:right this means the
scrollbar now sits at the screen's right edge.
- Update :h tabpanel-scroll to describe the new, align-
independent placement.
- Add Test_tabpanel_scrollbar_follows_curtab() and
Test_tabpanel_scrollbar_reaches_bottom() to exercise the
regressions fixed by items 2 and 3.

related: #19979


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/20052

Commit Summary

  • 302fb72 tabpanel: scrollbar completion, follow curtab, right-edge layout

File Changes

(6 files)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20052@github.com>

h_east

unread,
Apr 23, 2026, 7:51:23 PM (17 hours ago) Apr 23
to vim/vim, Subscribed
h-east left a comment (vim/vim#20052)

@mattn
Could you please review it?
In particular, regarding point 4, I've changed the scrollbar's position when tabpanelopt=align:right,scrollbar, so please check it.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20052/c4309200035@github.com>

mattn

unread,
Apr 23, 2026, 9:03:19 PM (15 hours ago) Apr 23
to vim/vim, Subscribed

@mattn commented on this pull request.


In src/tabpanel.c:

> @@ -48,6 +48,7 @@ static bool tpl_scrollbar = false;
 static int tpl_scroll_offset = 0;
 static int tpl_total_rows = 0;
 static int tpl_scrollbar_col = -1;	// screen column of scrollbar, -1 if none
+static tabpage_T *tpl_last_curtab = NULL;  // last curtab seen by draw_tabpanel

This tpl_last_curtab can be a dangling pointer.

It should be reset like below

if (curtab == tpl_last_curtab)
  tpl_last_curtab = NULL;


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20052/review/4167149800@github.com>

mattn

unread,
Apr 23, 2026, 9:04:44 PM (15 hours ago) Apr 23
to vim/vim, Subscribed

@mattn commented on this pull request.


In src/tabpanel.c:

> @@ -48,6 +48,7 @@ static bool tpl_scrollbar = false;
 static int tpl_scroll_offset = 0;
 static int tpl_total_rows = 0;
 static int tpl_scrollbar_col = -1;	// screen column of scrollbar, -1 if none
+static tabpage_T *tpl_last_curtab = NULL;  // last curtab seen by draw_tabpanel

It should be reset if tabpanelopt is modified.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20052/review/4167154859@github.com>

mattn

unread,
Apr 23, 2026, 9:09:00 PM (15 hours ago) Apr 23
to vim/vim, Subscribed

@mattn commented on this pull request.


In src/tabpanel.c:

> +    static void
+follow_curtab_if_needed(int curtab_row)
+{
+    if (!tpl_scroll || Rows <= 0 || curtab == tpl_last_curtab)
+	return;
+
+    if (curtab_row < tpl_scroll_offset)
+	tpl_scroll_offset = curtab_row;
+    else if (curtab_row >= tpl_scroll_offset + Rows)
+	tpl_scroll_offset = curtab_row - Rows + 1;
+
+    if (tpl_scroll_offset < 0)
+	tpl_scroll_offset = 0;
+    if (tpl_total_rows > Rows
+	    && tpl_scroll_offset > tpl_total_rows - Rows)
+	tpl_scroll_offset = tpl_total_rows - Rows;

Upper clamp only active when tpl_total_rows > Rows

Probably this part is better to be:

      int max_offset = tpl_total_rows > Rows ? tpl_total_rows - Rows : 0;

      if (tpl_scroll_offset < 0)
        tpl_scroll_offset = 0;
      else if (tpl_scroll_offset > max_offset)
        tpl_scroll_offset = max_offset;


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20052/review/4167172942@github.com>

Reply all
Reply to author
Forward
0 new messages