Skip to content

Conversation

@majiayu000
Copy link

Fixes #4620

Changes

  • Fix ANSI color offset calculation in --no-hscroll mode to use character indices instead of display width
  • This correctly handles zero-width characters (combining marks, control chars) where character count differs from column width

When using --no-hscroll with --ansi, the color offset constraints were
incorrectly using display width (maxWidth) instead of character indices
(len(runes)). This caused colors to be cut off prematurely when the text
contained zero-width characters like combining marks or control characters.

The fix changes the offset constraints to use the actual character count
of the trimmed runes array, ensuring colors properly cover all visible
characters regardless of zero-width characters.

Fixes junegunn#4620

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: majiayu000 <[email protected]>
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.

Wrong placement of ‘ANSI colour off’ with --no-hscroll when the string contains zero-width characters

1 participant