Skip to content

Fix pinned tab causing resize loop on adjacent tab#41884

Merged
smitbarmase merged 3 commits intozed-industries:mainfrom
abulgit:fix-tab-issue
Nov 13, 2025
Merged

Fix pinned tab causing resize loop on adjacent tab#41884
smitbarmase merged 3 commits intozed-industries:mainfrom
abulgit:fix-tab-issue

Conversation

@abulgit
Copy link
Contributor

@abulgit abulgit commented Nov 4, 2025

Closes #41467

My first PR in Zed, any guidance or tips are appreciated.

This fixes the flickering/resize loop that occurred on the tab immediately to the right of a pinned tab.

Removed the conditional border on the pinned tabs container. The border was a visual indicator to show when unpinned tabs were scrolled, but it wasn't essential and was causing the layout thrashing.

Release Notes:

  • Fixed

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Nov 4, 2025
Copy link
Member

@smitbarmase smitbarmase left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is the right way to handle this. This code is essential to add border when there are large amount of unpinned tabs and are scrolled.

Since this PR results in something like this:

Image

I'm not able to reproduce this issue, but can you inspect is_scrollable and is_scrolled bool and figure which one of them is flipping on alternate renders?

We might have to go deeper in checking if tab_bar_scroll_handle.offset().x is flipping to 0 every once in a while or is ittab_bar_scroll_handle.max_offset().width.

@abulgit
Copy link
Contributor Author

abulgit commented Nov 4, 2025

Thank you so much @smitbarmase for guiding me to tackle this issue.
So I added some debug logging to see what was happening. Turns out both values were flipping, but the root cause was max_offset toggling between 0px and 0.8px.

Here's my observation from logs

When no border: max_offset=0.8px -> is_scrollable=true -> border gets added
When border added: available space shrinks -> max_offset=0px -> is_scrollable=false -> border removed ->
and it repeats forever

The 0.8px difference is smaller than the border width, so it creates a loop.

So I changed the scrollability check from !max_scroll.is_zero() to max_scroll > px(2.0). This ignores tiny subpixel differences while still showing the border when tabs are actually scrollable. and it works!

Copy link
Member

@smitbarmase smitbarmase left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, that’s a nice fix! I moved the code back to children since we should only run all these comparisons when necessary. Thanks for working on this.

@smitbarmase smitbarmase merged commit 03fad4b into zed-industries:main Nov 13, 2025
23 checks passed
11happy pushed a commit to 11happy/zed that referenced this pull request Dec 1, 2025
…dustries#41884)

Closes zed-industries#41467 

My first PR in Zed, any guidance or tips are appreciated.

This fixes the flickering/resize loop that occurred on the tab
immediately to the right of a pinned tab.

Removed the conditional border on the pinned tabs container. The border
was a visual indicator to show when unpinned tabs were scrolled, but it
wasn't essential and was causing the layout thrashing.

Release Notes:

- Fixed

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pinned tab causes resize loop on tab to its right

3 participants