Skip to content

fix(input): let the scroll reach an inline completion's ghost lines - #9

Merged
trancong12102 merged 1 commit into
mainfrom
fix/ghost-lines-scroll
Oct 3, 2026
Merged

trancong12102 merged 1 commit into
mainfrom
fix/ghost-lines-scroll

Conversation

@trancong12102

Copy link
Copy Markdown

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 used rows × 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_to sets 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:

assertion `left == right` failed
  left: -198px
 right: -900px

The fix

resolve_scroll_top now clamps with the same max(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.
  • fmt is clean.
  • Clippy reports nothing in input/base/element.rs.

No upstream PR covers this: the commit is ours (62a6c40).

🤖 Generated with Claude Code

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>
@trancong12102
trancong12102 merged commit 289dec2 into main Oct 3, 2026
8 of 12 checks passed
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