Skip to content

Commit 03fad4b

Browse files
abulgitsmitbarmase
andauthored
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 <[email protected]>
1 parent c626e77 commit 03fad4b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

crates/workspace/src/pane.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use futures::{StreamExt, stream::FuturesUnordered};
1919
use gpui::{
2020
Action, AnyElement, App, AsyncWindowContext, ClickEvent, ClipboardItem, Context, Corner, Div,
2121
DragMoveEvent, Entity, EntityId, EventEmitter, ExternalPaths, FocusHandle, FocusOutEvent,
22-
Focusable, IsZero, KeyContext, MouseButton, MouseDownEvent, NavigationDirection, Pixels, Point,
22+
Focusable, KeyContext, MouseButton, MouseDownEvent, NavigationDirection, Pixels, Point,
2323
PromptLevel, Render, ScrollHandle, Subscription, Task, WeakEntity, WeakFocusHandle, Window,
2424
actions, anchored, deferred, prelude::*,
2525
};
@@ -3074,6 +3074,7 @@ impl Pane {
30743074
}
30753075
let unpinned_tabs = tab_items.split_off(self.pinned_tab_count);
30763076
let pinned_tabs = tab_items;
3077+
30773078
TabBar::new("tab_bar")
30783079
.when(
30793080
self.display_nav_history_buttons.unwrap_or_default(),
@@ -3097,8 +3098,10 @@ impl Pane {
30973098
.children(pinned_tabs.len().ne(&0).then(|| {
30983099
let max_scroll = self.tab_bar_scroll_handle.max_offset().width;
30993100
// We need to check both because offset returns delta values even when the scroll handle is not scrollable
3100-
let is_scrollable = !max_scroll.is_zero();
31013101
let is_scrolled = self.tab_bar_scroll_handle.offset().x < px(0.);
3102+
// Avoid flickering when max_offset is very small (< 2px).
3103+
// The border adds 1-2px which can push max_offset back to 0, creating a loop.
3104+
let is_scrollable = max_scroll > px(2.0);
31023105
let has_active_unpinned_tab = self.active_item_index >= self.pinned_tab_count;
31033106
h_flex()
31043107
.children(pinned_tabs)

0 commit comments

Comments
 (0)