Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F18936058
D11328.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D11328.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
@@ -124,12 +124,18 @@
$columns = array();
foreach ($this->columns as $key => $column) {
- $columns[] = PhutilConsoleFormatter::formatString(
- '**%s**',
- $this->alignString(
+ if (!$this->shouldAddSpacing($key, $column)) {
+ $column_str = $column['title'];
+ } else {
+ $column_str = $this->alignString(
$column['title'],
$this->getWidth($key),
- idx($column, 'align', self::ALIGN_LEFT)));
+ idx($column, 'align', self::ALIGN_LEFT));
+ }
+
+ $columns[] = PhutilConsoleFormatter::formatString(
+ '**%s**',
+ $column_str);
}
$output .= $this->formatRow($columns);
@@ -148,10 +154,14 @@
$columns = array();
foreach ($this->columns as $key => $column) {
- $columns[] = $this->alignString(
- (string)idx($data, $key, ''),
- $this->getWidth($key),
- idx($column, 'align', self::ALIGN_LEFT));
+ if (!$this->shouldAddSpacing($key, $column)) {
+ $columns[] = (string)idx($data, $key, '');
+ } else {
+ $columns[] = $this->alignString(
+ (string)idx($data, $key, ''),
+ $this->getWidth($key),
+ idx($column, 'align', self::ALIGN_LEFT));
+ }
}
$output .= $this->formatRow($columns);
@@ -180,6 +190,27 @@
/* -( Internals )---------------------------------------------------------- */
/**
+ * Returns if the specified column should have spacing added.
+ *
+ * @return bool
+ */
+ private function shouldAddSpacing($key, $column) {
+ if (!$this->borders) {
+ if (last_key($this->columns) === $key) {
+ if (idx($column, 'align', self::ALIGN_LEFT) === self::ALIGN_LEFT) {
+ // Don't add extra spaces to this column since it's the last column,
+ // left aligned, and we're not showing borders. This prevents
+ // unnecessary empty lines from appearing when the extra spaces
+ // wrap around the terminal.
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ /**
* Returns the column IDs.
*
* @return list<string>
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Nov 11 2025, 7:43 PM (5 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
11799338
Default Alt Text
D11328.diff (2 KB)
Attached To
Mode
D11328: Ensure empty lines do not appear with large widths on last column of PhutilConsoleTable
Attached
Detach File
Event Timeline
Log In to Comment