Skip to content

list: measure an existing row when the configured item is absent - #7

Closed
grishy wants to merge 3 commits into
sg-review-basefrom
sg-list-measurement-fallback
Closed

list: measure an existing row when the configured item is absent#7
grishy wants to merge 3 commits into
sg-review-basefrom
sg-list-measurement-fallback

Conversation

@grishy

@grishy grishy commented Sep 5, 2026

Copy link
Copy Markdown
Owner

List measures one row to determine the height of its items. When the configured row is missing, it measures an empty element at zero height. A remaining row can then overlap the section footer.

The measurement row is chosen in this order:

  1. Use the configured index if both its section and row exist.
  2. Otherwise, use the first row in the first non-empty section.
  3. If all sections are empty, skip item measurement.

The fallback is only used for the current measurement. It does not overwrite item_to_measure_index, which is the caller's setting. For example, if row 5 is configured but filtering leaves only two rows, the list measures row 0 without changing the setting to 0. Once row 5 is a valid index again, the list measures it. This preserves the configured position, not the identity of a particular item.

The choice stays in prepare_items_if_needed, where List already measures its rows. Selection, filtering, and header/footer measurement are unchanged.

Screenshots

Both captures use the same fixed-data Story setup, with an empty first section and search results replaced on each query. Only the measurement fix differs. This setup is not included in the PR.

Before After
Acme overlaps its section footer before the fix Acme and its footer occupy separate space after the fix

How to Test

The regression reproduces the problem without any Story changes:

cargo test -p gpui-component --lib measures_an_existing_row_when_the_requested_item_is_absent --locked

Without the fix, the test fails with 0px instead of 36px. It covers missing rows and sections, an empty list, and a configured index becoming invalid and then valid again. Different row heights verify that measurement returns to the configured index without resetting it.

I also manually checked filtering, empty results, clearing the query, repeated searches, and window resizing on macOS. Rows and the section footer stayed separated.

Automated checks
cargo test -p gpui-base -p gpui-component --lib --locked
cargo clippy -p gpui-base -p gpui-component -p gpui-component-story --all-targets --locked -- -D warnings

771 base and 419 component tests passed, along with strict Clippy, formatting, and the diff whitespace check.

Windows and Linux runtime were not tested.

Checklist

  • Read CONTRIBUTING.md and followed the guidelines.
  • Reviewed the final patch, including the AI-assisted changes.
  • Manually tested the related Story example on macOS.

AI assistance

I tested this fix in my application, then asked OpenAI's gpt-6-astra to extract it into a standalone PR. The agent prepared the patch, regression test, and description, and ran the automated checks. I reviewed the extracted patch, requested corrections, and manually tested it again on macOS.

An absent measurement row produces a zero-height wrapper even when other
sections contain items. Validate the configured index and fall back to a
real row without overwriting the caller's preference.
@grishy

grishy commented Sep 5, 2026

Copy link
Copy Markdown
Owner Author

Opened upstream as longbridge#2975 with the reviewed patch and description. Closing this review PR.

@grishy grishy closed this Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant