Page MenuHomePhabricator

D9583.diff
No OneTemporary

D9583.diff

diff --git a/src/console/PhutilConsoleTable.php b/src/console/PhutilConsoleTable.php
--- a/src/console/PhutilConsoleTable.php
+++ b/src/console/PhutilConsoleTable.php
@@ -117,7 +117,7 @@
'**%s**',
$this->alignString(
$column['title'],
- $this->widths[$key],
+ $this->getWidth($key),
idx($column, 'align', self::ALIGN_LEFT)));
}
@@ -139,7 +139,7 @@
foreach ($this->columns as $key => $column) {
$columns[] = $this->alignString(
(string)idx($data, $key, ''),
- $this->widths[$key],
+ $this->getWidth($key),
idx($column, 'align', self::ALIGN_LEFT));
}
@@ -184,11 +184,17 @@
* @return int
*/
protected function getWidth($key) {
- return idx($this->widths, $key) + 2 * $this->padding;
+ $width = max(
+ idx($this->widths, $key),
+ phutil_utf8_console_strlen(
+ idx(idx($this->columns, $key, array()), 'title', '')));
+
+ return $width + 2 * $this->padding;
}
protected function alignString($string, $width, $align) {
- $num_padding = $width - phutil_utf8_console_strlen($string);
+ $num_padding = $width -
+ (2 * $this->padding) - phutil_utf8_console_strlen($string);
switch ($align) {
case self::ALIGN_LEFT:

File Metadata

Mime Type
text/plain
Expires
Wed, May 7, 9:58 PM (1 d, 11 m ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7225216
Default Alt Text
D9583.diff (1 KB)

Event Timeline