feat(ui): scroll the reference badges instead of cropping them - #49
Merged
Conversation
A commit carrying more references than the subject column is wide lost the last of them: the cell is one `h_flex` with `overflow_hidden`, so the badges past the edge were simply not drawn, and the subject with them. On this repository's tip, six refs left no subject visible at all. The badges now sit in a strip of their own that scrolls horizontally, capped at half the cell so the subject always keeps its share. Nothing is added to draw a scrollbar: the strip scrolls under the trackpad and shows no chrome. `restrict_scroll_to_axis` is the part that is not optional, and not what the name suggests. It defaults to false (`gpui::style`), and with it unset a scrollable-x element treats a *vertical* delta as horizontal whenever its own y overflow is not `Scroll` — so a vertical gesture anywhere over a badge strip would have scrolled the badges sideways and left the table standing still. It is set explicitly here. The badges and their container are `flex_none`: an overflow container's children still take part in flex layout, so without it they would compress to fit the strip rather than overflow it, and there would be nothing to scroll. The strip is keyed by commit id rather than by row index. gpui stores the scroll offset per element id, and a row index is a position in a virtualised list — it belongs to a different commit as soon as the history is filtered or reloaded, which would carry one commit's scroll position onto another's badges.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A commit carrying more references than the subject column is wide lost the last of them. The cell is one
h_flexwithoverflow_hidden, so badges past the edge were simply not drawn — and the subject with them. On this repository's tip, six refs left no subject visible at all.The change
The badges move into a strip of their own that scrolls horizontally, capped at half the cell so the subject always keeps its share. Nothing draws a scrollbar: the strip scrolls under the trackpad and shows no chrome.
Three things that are not obvious
restrict_scroll_to_axisis not optional, and not what the name suggests. It defaults tofalse, and with it unset a scrollable-x element treats a vertical delta as horizontal whenever its own y overflow is notScroll(gpui/src/elements/div.rs:3221). A vertical gesture anywhere over a badge strip would have scrolled the badges sideways and left the table standing still. Found by reading gpui's source rather than its docs, whichCLAUDE.mdalready warns are unreliable here.The badges and their container are
flex_none. An overflow container's children still take part in flex layout, so without it they compress to fit the strip rather than overflow it — and there is nothing left to scroll.The strip is keyed by commit id, not row index. gpui stores the scroll offset per element id, and a row index is a position in a virtualised list: it belongs to a different commit as soon as the history is filtered or reloaded, which would carry one commit's scroll position onto another's badges.
Testing
cargo clippy --all-targets -- -D warningsandcargo fmt --all --checkpass. No test: this is layout, and the delegate's existing tests cover row selection rather than element structure.Not confirmed in the running app. gitr is single-instance and the installed binary held the socket, so I never got this build in front of a human eye. Worth a look at a row with many refs, and at whether a horizontal gesture over a strip also drags the table's own horizontal scroll — both elements are in the hit-test chain and would each apply the delta.