Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15578967
D9583.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D9583.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D9583: Fix the width of `PhutilConsoleTable` if the header row is wider than the data rows.
Attached
Detach File
Event Timeline
Log In to Comment