Skip to content

gpui: Recalculate list layout after the window has been resized#51414

Merged
ChristopherBiscardi merged 2 commits intozed-industries:mainfrom
feitreim:bugfix-recalc-list-layouts-after-resize
Mar 13, 2026
Merged

gpui: Recalculate list layout after the window has been resized#51414
ChristopherBiscardi merged 2 commits intozed-industries:mainfrom
feitreim:bugfix-recalc-list-layouts-after-resize

Conversation

@feitreim
Copy link
Copy Markdown
Contributor

@feitreim feitreim commented Mar 12, 2026

Closes #51417

I noticed this bug in the settings menu where when I opened the settings menu, I could not scroll down through all the available options, eg. on the initial page I wasn't able to scroll down to privacy. When I saw that no one else had reported this issue, I figured it may be due to my setup, and it turns out that using Aerospace, the window manager I use, was what made this bug visible to me. Because aerospace resizes the window right after it launches, the originally computed heights for the list are incorrect, meaning the scroll bar is the wrong size as well.

in the relevant code there was a comment that says "If the width of the list has changed, invalidate all cached item heights" which wasn't incorrect per-se, but it just invalidated them without triggering any re-computation, causing incorrect scroll bars.

My intuition is that window resizes/events that change the width of the list bounds are fairly rare, so there shouldn't be a large performance hit from the change.

Also implemented a test that directly showcases the behavior, if you run the test without the change it fails, as the max_offset_for_scrollbar will be wrong.

Videos:

Before

before_fix.mov

After:

fixed.mov

[x] Tests
[x] Video of behavior

Release Notes:

  • gpui: fixed list height re-computation when the list width changes.

comment says "If the width of the list has changed, invalidate all
cached item heights" which wasn't incorrect per-se, but it just
invalidated them without triggering any recomputation, causing incorrect
scroll bars.
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Mar 12, 2026
@zed-community-bot zed-community-bot bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Mar 12, 2026
@maxdeviant maxdeviant changed the title gpui: recalculate list layout after the window has been resized. gpui: Recalculate list layout after the window has been resized Mar 12, 2026
Copy link
Copy Markdown
Contributor

@ChristopherBiscardi ChristopherBiscardi left a comment

Choose a reason for hiding this comment

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

I've reproduced this with a similar window management software (yabai) and confirmed that the fix works.

before:

screenshot-2026-03-12-at-16.25.26-converted.mp4

after:

screenshot-2026-03-12-at-16.29.22-converted.mp4

Test fails without the fix, and passes with the fix.

I think this fix is correct, since the width is being invalidated and this is also what is done when height changes in remeasure

@ChristopherBiscardi ChristopherBiscardi merged commit 7b9afc8 into zed-industries:main Mar 13, 2026
29 checks passed
@ChristopherBiscardi
Copy link
Copy Markdown
Contributor

Thanks!

@feitreim feitreim deleted the bugfix-recalc-list-layouts-after-resize branch March 13, 2026 00:18
tommyming pushed a commit to tommyming/zed that referenced this pull request Mar 13, 2026
…industries#51414)

Closes zed-industries#51417

I noticed this bug in the settings menu where when I opened the settings
menu, I could not scroll down through all the available options, eg. on
the initial page I wasn't able to scroll down to privacy. When I saw
that no one else had reported this issue, I figured it may be due to my
setup, and it turns out that using Aerospace, the window manager I use,
was what made this bug visible to me. Because aerospace resizes the
window right after it launches, the originally computed heights for the
list are incorrect, meaning the scroll bar is the wrong size as well.

in the relevant code there was a comment that says "If the width of the
list has changed, invalidate all cached item heights" which wasn't
incorrect per-se, but it just invalidated them without triggering any
re-computation, causing incorrect scroll bars.

My intuition is that window resizes/events that change the width of the
list bounds are fairly rare, so there shouldn't be a large performance
hit from the change.

Also implemented a test that directly showcases the behavior, if you run
the test without the change it fails, as the max_offset_for_scrollbar
will be wrong.

Videos:

Before 


https://github.com/user-attachments/assets/2b680222-7071-4098-863f-519361f0756a

After:


https://github.com/user-attachments/assets/1222a299-23d7-4007-8e88-55d2daccce64


[x] Tests
[x] Video of behavior


Release Notes:

- gpui: fixed list height re-computation when the list width changes.
Yamrc added a commit to NeoNekos/NekoWG that referenced this pull request Mar 15, 2026
- 修复设置菜单无法滚动显示全部选项的问题
- 解决窗口管理器(如Aerospace)导致的列表高度计算不正确
- 修改窗口大小变化时无效化缓存的行为,确保滚动条正确显示
- 增加测试,验证修改后的行为

源提交: zed-industries/zed#51414
Yamrc added a commit to NeoNekos/NekoWG that referenced this pull request Mar 15, 2026
- 修复设置菜单无法滚动显示全部选项的问题
- 解决窗口管理器(如Aerospace)导致的列表高度计算不正确
- 修改窗口大小变化时无效化缓存的行为,确保滚动条正确显示
- 增加测试,验证修改后的行为

源提交: zed-industries/zed#51414
Yamrc added a commit to NeoNekos/NekoWG that referenced this pull request Mar 15, 2026
- 修复设置菜单无法滚动显示全部选项的问题
- 解决窗口管理器(如Aerospace)导致的列表高度计算不正确
- 修改窗口大小变化时无效化缓存的行为,确保滚动条正确显示
- 增加测试,验证修改后的行为

源提交: zed-industries/zed#51414
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 first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot scroll to all available settings after window resize.

2 participants