Skip to content
This repository was archived by the owner on Jun 18, 2022. It is now read-only.

Commit 5311a4b

Browse files
Merge pull request wp-cli#94 from wp-cli/decolorize-safe-str-pad
Only decolorize in `cli\safe_str_pad()` when colorizing
2 parents d0564da + f596b77 commit 5311a4b

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

lib/cli/cli.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,9 @@ function safe_substr( $str, $start, $length = false ) {
202202
* @return string
203203
*/
204204
function safe_str_pad( $string, $length ) {
205+
$cleaned_string = Colors::shouldColorize() ? Colors::decolorize( $string ) : $string;
205206
// Hebrew vowel characters
206-
$cleaned_string = preg_replace( '#[\x{591}-\x{5C7}]+#u', '', Colors::decolorize( $string ) );
207+
$cleaned_string = preg_replace( '#[\x{591}-\x{5C7}]+#u', '', $cleaned_string );
207208
if ( function_exists( 'mb_strwidth' ) && function_exists( 'mb_detect_encoding' ) ) {
208209
$real_length = mb_strwidth( $cleaned_string, mb_detect_encoding( $string ) );
209210
} else {

tests/test-table-ascii.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public function testDrawOneColumnTable() {
7474
* At the same time it checks that `green` defined in `cli\Colors` really looks as `green`.
7575
*/
7676
public function testDrawOneColumnColoredTable() {
77+
Colors::enable( true );
7778
$headers = array('Test Header');
7879
$rows = array(
7980
array(Colors::colorize('%Gx%n', true)),

0 commit comments

Comments
 (0)