Terminal text-wrapping rewritten to correctly handle ANSI codes, with a verified fallback
Claude Code's terminal text-wrapping logic (which decides how to break long lines of text to fit the terminal width) has been rewritten to properly account for ANSI escape and control sequences, the invisible codes terminals use for things like color and cursor movement. The new approach temporarily replaces these sequences with a placeholder character while wrapping, then verifies that the wrapped result still reconstructs the original text correctly. If that verification fails, it falls back to a simpler, character-based wrapping method and marks the result as "degraded." This replaces the previous text-measurement approach entirely.
This reduces the chance that colored or otherwise styled terminal output gets wrapped incorrectly, while the verification-and-fallback approach means a wrapping bug degrades gracefully to a simpler method instead of producing broken output.