Improve text wrapping to fill lines completely with ANSI support - #38
Merged
github-actions[bot] merged 1 commit intoJul 26, 2026
Merged
Conversation
The multi-line output previously wrapped only at info-block boundaries, pushing an entire block to the next line when it didn't fit and leaving unused space at the end of each line. Replace that with continuous character-fill wrapping: each line is filled to line_wrap_length before breaking, splitting in the middle of a block when needed. Add wrapAnsiText, which counts visible width (ignoring ANSI escape sequences), re-applies the active color at the start of each wrapped line so colors survive a mid-block break, and keeps emoji surrogate pairs intact. Remove the now-unused removeAnsiCodes helper. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PTMmeo1oiSAEj9vW5UQ2M1
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Summary
Replaced the simple block-boundary text wrapping logic with a character-level wrapping algorithm that fills each line completely before moving to the next, even if it means breaking in the middle of an info block. This eliminates wasted space at the end of lines while properly handling ANSI color codes and emoji.
Key Changes
removeAnsiCodes()withwrapAnsiText(): The new function wraps text to a maximum visible width while intelligently handling ANSI escape sequences and emoji surrogate pairsImplementation Details
wrapAnsiText()function tracks the active ANSI color state and reapplies it when wrapping to a new line (unless a reset sequence was encountered)\x1b[and reading until the trailingmcharacterhttps://claude.ai/code/session_01PTMmeo1oiSAEj9vW5UQ2M1