Repository navigation
fix(input): let the scroll reach an inline completion's ghost lines - #9
Merged
Merged
Conversation
62a6c40 resolves the vertical scroll before layout and clamps it to the text's height, leaving inline-completion ghost lines out on the grounds that they only add height. The paint sizes the scrollable height with them (the larger of the empty bottom and the ghost lines), so a scroll down to ghost lines under the last line persisted, and the next layout clamped it back above them: they could never be scrolled to. The clamp now takes the same larger of the two, counting the ghost lines from the completion's text without shaping them. The new test scrolls an editor with 30 ghost lines under its last line to the foot: the offset held at -900 px; before the fix the next frame pulled it back to -198 px. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
The defect
Commit 62a6c40 resolves the vertical scroll before layout. It clamps the scroll to the text's height and leaves inline-completion ghost lines out of it, on the grounds that they only ever add height, so the clamped range sits inside the one the paint keeps.
The reasoning fails because the two heights differ. The paint sizes the scrollable height as
rows × line_height + max(empty bottom, ghost lines), while the resolve step usedrows × line_height + empty bottom. A scroll down to ghost lines under the last line is accepted by the paint, and the next layout then clamps it back above them. Ghost lines past the text's end can never be scrolled into view.The proof
The new test
ghost_lines_below_the_last_line_can_be_scrolled_tosets up a 10-line editor with the caret on its last line and an inline completion with 30 ghost lines. It scrolls to the foot of the scrollable height, as the wheel would, then draws twice.Before the fix, the offset is pulled from -900 px back to -198 px:
The fix
resolve_scroll_topnow clamps with the samemax(empty bottom, ghost lines)the paint uses. It counts the ghost lines from the completion's text without shaping them: the lines after the first, shown while the input has focus. With the fix, the offset holds at -900 px across frames.Checks
cargo test -p gpui-base -p gpui-component --lib: 1339 and 601 passed.input/base/element.rs.No upstream PR covers this: the commit is ours (62a6c40).
🤖 Generated with Claude Code