Fix colorization preservation in wrapped table cells #6197
Closed
+780
−0
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.
When table cells containing colorized text wrap across multiple lines, ANSI escape sequences are lost on continuation lines, rendering them as plain text.
Root Cause
The issue is in
wp-cli/php-cli-toolslibrary'sAsciitable renderer. When text exceeds column width and wraps, the wrapping logic (row()method) splits strings without preserving active ANSI color codes.Solution
Since the bug is in the vendor dependency, this PR provides:
Implementation (as patch)
patches/php-cli-tools-colorization-fix.patch- Unified diff forlib/cli/table/Ascii.php\033[0mreset at wrap boundariesgetLastActiveAnsiColor()helper to detect active escape sequencesDocumentation
FIX_DOCUMENTATION.md- Technical implementation details with code examplesREADME_COLORIZATION_FIX.md- Integration guide for applying to upstreamVISUAL_DEMO.md- Before/after comparison with actual ANSI outputSUMMARY.md- Complete status and next stepsTesting
features/formatter.feature- Added test scenario documenting expected behaviorExample
Before:
After:
Next Steps
wp-cli/php-cli-toolsrepositorywp-cli/wp-cliafter releaseOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.