Skip to content

input: Measure the horizontal scroll extent from laid-out lines - #3604

Merged
huacnlee merged 2 commits into
longbridge:mainfrom
YidaWeng:fix/input-horizontal-scroll-width
Oct 20, 2026
Merged

huacnlee merged 2 commits into
longbridge:mainfrom
YidaWeng:fix/input-horizontal-scroll-width

Conversation

@YidaWeng

Copy link
Copy Markdown
Contributor

Closes #3529

Description

TextElement sized the horizontal scroll range from the line with the most UTF-8 bytes, and shaped only that line. A shorter line with wider glyphs can render past that width, so with soft wrap disabled the horizontal scrollbar stopped before the end of the line and the rest was unreachable.

The visible lines are already shaped each frame, so the extent now takes their widest measured width as a lower bound alongside the byte-length candidate. The value stays in the existing per-document and per-style cache, so the extent does not shrink when the wide line scrolls out of view; edits and font changes invalidate it as before. Single-line inputs use the same path, and soft-wrapped inputs continue to use the viewport width.

Screenshot

Not applicable: the change is covered by a frame-stepped layout test.

How to Test

  • cargo test -p gpui-base --lib --features test-support horizontal_scroll_extent_covers_the_widest_laid_out_line
    • The fixture has a byte-long but narrower first line (e + 200 combining marks) and a shorter, wider second line (W × 300). It scrolls fully right and asserts the caret at the end of the wider line lands inside the viewport. It repeats after editing the wider line to W × 400 and after growing the rem size from 16px to 24px. Without the fix the caret is left at x=1180px in a 240px viewport.
  • cargo test -p gpui-base --lib --features test-support — 1432 passed.
  • cargo test -p gpui-component --lib — 698 passed.
  • cargo test -p gpui-kit --test integration --features "test-support,component" — 413 passed.
  • cargo clippy -p gpui-base --all-targets --features test-support -- -D warnings — clean (only pre-existing workspace dependency warnings).
  • cargo fmt --all -- --check.

No public API changes.

Checklist

  • I have read the CONTRIBUTING document and followed the guidelines.
  • Reviewed the changes in this PR and confirmed AI generated code (If any) is accurate.
  • Passed cargo run for story tests related to the changes.
  • Tested macOS, Windows and Linux platforms performance (if the change is platform-specific)

The horizontal scroll range was sized from the line with the most UTF-8
bytes, and only that line was shaped. A shorter line with wider glyphs
rendered past that width, so the scrollbar could not reach its end when
soft wrap was disabled (longbridge#3529).

The visible lines are already shaped during layout, so use their widest
measured width as a lower bound alongside the byte-length candidate. Keep
it in the existing per-document and per-style cache so the extent does not
shrink when the wide line scrolls away; edits and font changes invalidate
the cache as before.
@YidaWeng
YidaWeng force-pushed the fix/input-horizontal-scroll-width branch from 0e581ee to 68b785f Compare October 20, 2026 04:25
huacnlee
huacnlee previously approved these changes Oct 20, 2026
@huacnlee
huacnlee merged commit ade05d0 into longbridge:main Oct 20, 2026
@YidaWeng
YidaWeng deleted the fix/input-horizontal-scroll-width branch October 21, 2026 04:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gpui-base editor Content not fully displayed, Horizontal scrolling cannot reveal the full line when soft wrap is disabled

2 participants