Subject: bug#37667: 27.0.50; Tab Bar display problems with more than 5 tabs

From: Juri Linkov <[email-masked]>
Date: Thu, 31 Oct 2019 22:46:49 +0200

>> Before starting to search the current tab, the code needs to known
>> whether truncation really occurred.
>
> Can you explain why?  Don't you keep the ordinal number of the current
> tab somewhere?  If not, can you keep it?  Given the number, finding
> the tab should be trivial, no?  (At least for some values of "find".)

Detection of truncation is necessary as a separate function to decide
whether to display arrow buttons in the tab-line.  When the tab-line
is not truncated and displayed in its entirety, then there is no need
to display arrow buttons for hscrolling.

>> We need to detect whether the current tab is before the right truncation point
>> (so it is visible), or after the truncation (so the current tab is not visible).
>
> You already keep the number of tabs you've hscrolled off the display,
> right?

Yes, the number of hscrolled tabs is kept in the window parameter.

> So if you also keep the number of the current tab, the above
> decisions become trivial, no?  Or what am I missing?

To get the ordinal number of the current tab is trivial indeed, but when
due to the large number of tabs preceding the current tab on the left side
from it, it gets pushed off-screen behind the right window edge, we need
to set the window parameter for the number of hscrolled tabs to such
number of tabs that will reduce the length of displayed tabs on
the left side from the current tab, so it becomes visible again.

C code is only need to calculate the number of tabs to cut on the left
side from the current tab to make it visible.