Skip to content

fix(wrap): keep wrapped text and cursor visible - #38

Merged
srothgan merged 3 commits into
mainfrom
fix/wrapped-layout-cursor-visibility
Aug 23, 2026
Merged

srothgan merged 3 commits into
mainfrom
fix/wrapped-layout-cursor-visibility

Conversation

@srothgan

Copy link
Copy Markdown
Owner

Problem

Active wrapping could place the native cursor outside the textarea when content exactly filled the drawable width. In word-based modes, oversized words could also be clipped, and a trailing whitespace run could move atomically to a continuation row, briefly placing the cursor in the middle of an otherwise blank row.

Change Summary

  • Centralize text width, line-number width, and reserved-caret width in shared layout metrics used by measurement, rendering, cursor mapping, and hit testing.
  • Reserve a visible caret cell in every active wrapping mode while preserving horizontal scrolling for WrapMode::None.
  • Split oversized word content at grapheme boundaries so wrapped text is never clipped.
  • Make Word and WordOrGlyph behavior equivalent while retaining WordOrGlyph for source and serialization compatibility.
  • Consume whitespace runs one grapheme at a time so spaces fill the current visual row before excess whitespace wraps.

Test Evidence

  • cargo fmt --all -- --check
  • cargo clippy --all-targets -- -D warnings
  • cargo check --offline
  • cargo test
  • Windows-supported backend and feature matrices for crossterm 0.28, termwiz, no-backend, search, serde, and arbitrary
  • Full claude-code-rust consumer test and clippy suites against the local path dependency
  • Manual reproduction with trailing spaces at the right wrapping boundary

Breaking Changes

No source-level breaking changes. Wrapped modes can wrap one cell earlier because they now reserve space for the native caret. Word now splits oversized words at grapheme boundaries instead of allowing trailing content to be clipped, and WordOrGlyph remains available with the same corrected behavior. WrapMode::None retains horizontal scrolling.

- centralize wrapping, measurement, rendering, and hit-test geometry
- reserve a terminal cell for wrapped caret placement
- split oversized words instead of clipping their trailing characters
- retain WordOrGlyph as a documented compatibility variant
- add exact-width and alignment regression coverage
- Split word-mode whitespace runs into independently wrapable grapheme units.
- Fill remaining visual-row cells before wrapping excess whitespace.
- Keep Word and WordOrGlyph behavior compatible.
- Add regressions for whitespace wrapping and rendered cursor placement.
- Bump the crate and lockfile versions to 0.13.2.
- Document the wrapping fixes and shared layout architecture.
- Attribute the changes to PR #38 and @srothgan.
- Add the 0.13.2 comparison link.
@srothgan srothgan added the bug Unexpected problem or unintended behavior label Aug 23, 2026
@srothgan
srothgan merged commit dfaa7cf into main Aug 23, 2026
7 checks passed
@srothgan
srothgan deleted the fix/wrapped-layout-cursor-visibility branch August 23, 2026 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Unexpected problem or unintended behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant