Skip to content

gpui: Fix scroll_to_reveal_item scrolling for visible items#52565

Open
Skxxtz wants to merge 1 commit intozed-industries:mainfrom
Skxxtz:fix/scroll_to_reveal_item
Open

gpui: Fix scroll_to_reveal_item scrolling for visible items#52565
Skxxtz wants to merge 1 commit intozed-industries:mainfrom
Skxxtz:fix/scroll_to_reveal_item

Conversation

@Skxxtz
Copy link
Copy Markdown
Contributor

@Skxxtz Skxxtz commented Mar 27, 2026

Improved List Navigation: Nearest Scroll Strategy

Description

This PR refactors scroll_to_reveal_item in gpui to prevent unnecessary "jumping" when navigating through a list.

Previously, moving "Up" would aggressively snap the selected item to the top of the viewport even if it was already fully visible.

Previous behavior:

2026-03-27.11-43-34.mp4

New behavior:

2026-03-27.11-45-25.mp4

How:

The new implementation uses pixel-coordinate math (via SumTree cursors) to implement a Nearest scroll strategy:

  • If the item is already fully visible: The scroll position remains unchanged.
  • If the item is above the viewport: The list scrolls just enough to align the item's top with the viewport's top.
  • If the item is below the viewport: The list scrolls just enough to align the item's bottom with the viewport's bottom.

This creates a much smoother experience in the Launcher and other list-heavy interfaces where users frequently toggle between adjacent items.

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content is consistent with the UI/UX checklist
  • Tested locally on a project
  • Performance impact has been considered and is acceptable

Release Notes:

  • Fixed "jumpy" list scrolling by ensuring items only trigger a scroll when they are actually outside the visible area.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Mar 27, 2026
@zed-codeowner-coordinator zed-codeowner-coordinator bot requested review from a team, as-cii and dinocosta and removed request for a team March 27, 2026 10:47
@maxdeviant maxdeviant changed the title fix(gpui): fixed scroll_to_reveal_item scrolling even though item i… gpui: Fix scroll_to_reveal_item scrolling even though item list Mar 27, 2026
@maxdeviant maxdeviant changed the title gpui: Fix scroll_to_reveal_item scrolling even though item list gpui: Fix scroll_to_reveal_item scrolling for visible items Mar 27, 2026
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.

2 participants