workspace: Fix pinned tab causing resize loop on adjacent tab (#41884)

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

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
This commit is contained in:
Abul Hossain Khan
2025-11-14 01:52:57 +05:30
committed by GitHub
co-authored by Smit Barmase
parent c626e770a0
commit 03fad4b951
+5 -2
View File
@@ -19,7 +19,7 @@ use futures::{StreamExt, stream::FuturesUnordered};
use gpui::{
Action, AnyElement, App, AsyncWindowContext, ClickEvent, ClipboardItem, Context, Corner, Div,
DragMoveEvent, Entity, EntityId, EventEmitter, ExternalPaths, FocusHandle, FocusOutEvent,
Focusable, IsZero, KeyContext, MouseButton, MouseDownEvent, NavigationDirection, Pixels, Point,
Focusable, KeyContext, MouseButton, MouseDownEvent, NavigationDirection, Pixels, Point,
PromptLevel, Render, ScrollHandle, Subscription, Task, WeakEntity, WeakFocusHandle, Window,
actions, anchored, deferred, prelude::*,
};
@@ -3074,6 +3074,7 @@ impl Pane {
}
let unpinned_tabs = tab_items.split_off(self.pinned_tab_count);
let pinned_tabs = tab_items;
TabBar::new("tab_bar")
.when(
self.display_nav_history_buttons.unwrap_or_default(),
@@ -3097,8 +3098,10 @@ impl Pane {
.children(pinned_tabs.len().ne(&0).then(|| {
let max_scroll = self.tab_bar_scroll_handle.max_offset().width;
// We need to check both because offset returns delta values even when the scroll handle is not scrollable
let is_scrollable = !max_scroll.is_zero();
let is_scrolled = self.tab_bar_scroll_handle.offset().x < px(0.);
// Avoid flickering when max_offset is very small (< 2px).
// The border adds 1-2px which can push max_offset back to 0, creating a loop.
let is_scrollable = max_scroll > px(2.0);
let has_active_unpinned_tab = self.active_item_index >= self.pinned_tab_count;
h_flex()
.children(pinned_tabs)