Skip to content

Commit f99308f

Browse files
authored
Merge pull request #136 from wp-cli/135-fix-manual-width-attribution
Use forced width attribution as fallback only to avoid scrapping manual widths
2 parents 766653b + 554b262 commit f99308f

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

lib/cli/Table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public function display() {
136136
* @return array
137137
*/
138138
public function getDisplayLines() {
139-
$this->_renderer->setWidths($this->_width);
139+
$this->_renderer->setWidths($this->_width, $fallback = true);
140140
$border = $this->_renderer->border();
141141

142142
$out = array();

lib/cli/table/Ascii.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,16 @@ class Ascii extends Renderer {
3232
/**
3333
* Set the widths of each column in the table.
3434
*
35-
* @param array $widths The widths of the columns.
35+
* @param array $widths The widths of the columns.
36+
* @param bool $fallback Whether to use these values as fallback only.
3637
*/
37-
public function setWidths(array $widths) {
38+
public function setWidths(array $widths, $fallback = false) {
39+
if ($fallback) {
40+
foreach ( $this->_widths as $index => $value ) {
41+
$widths[$index] = $value;
42+
}
43+
}
44+
$this->_widths = $widths;
3845

3946
if ( is_null( $this->_constraintWidth ) ) {
4047
$this->_constraintWidth = (int) Shell::columns();

lib/cli/table/Renderer.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,15 @@ public function __construct(array $widths = array()) {
2525
/**
2626
* Set the widths of each column in the table.
2727
*
28-
* @param array $widths The widths of the columns.
28+
* @param array $widths The widths of the columns.
29+
* @param bool $fallback Whether to use these values as fallback only.
2930
*/
30-
public function setWidths(array $widths) {
31+
public function setWidths(array $widths, $fallback = false) {
32+
if ($fallback) {
33+
foreach ( $this->_widths as $index => $value ) {
34+
$widths[$index] = $value;
35+
}
36+
}
3137
$this->_widths = $widths;
3238
}
3339

0 commit comments

Comments
 (0)