mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 11:07:44 +00:00
Merge pull request #3442 from uutils/revert-3423-remove_trailing_spaces_in_rightmost_column
Revert "df: remove trailing spaces in rightmost column"
This commit is contained in:
commit
91ccdb6479
2 changed files with 6 additions and 15 deletions
|
@ -401,21 +401,12 @@ impl fmt::Display for Table {
|
||||||
while let Some(row) = row_iter.next() {
|
while let Some(row) = row_iter.next() {
|
||||||
let mut col_iter = row.iter().enumerate().peekable();
|
let mut col_iter = row.iter().enumerate().peekable();
|
||||||
while let Some((i, elem)) = col_iter.next() {
|
while let Some((i, elem)) = col_iter.next() {
|
||||||
let is_last_col = col_iter.peek().is_none();
|
|
||||||
|
|
||||||
match self.alignments[i] {
|
match self.alignments[i] {
|
||||||
Alignment::Left => {
|
Alignment::Left => write!(f, "{:<width$}", elem, width = self.widths[i])?,
|
||||||
if is_last_col {
|
|
||||||
// no trailing spaces in last column
|
|
||||||
write!(f, "{}", elem)?;
|
|
||||||
} else {
|
|
||||||
write!(f, "{:<width$}", elem, width = self.widths[i])?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Alignment::Right => write!(f, "{:>width$}", elem, width = self.widths[i])?,
|
Alignment::Right => write!(f, "{:>width$}", elem, width = self.widths[i])?,
|
||||||
}
|
}
|
||||||
|
|
||||||
if !is_last_col {
|
if col_iter.peek().is_some() {
|
||||||
// column separator
|
// column separator
|
||||||
write!(f, " ")?;
|
write!(f, " ")?;
|
||||||
}
|
}
|
||||||
|
|
|
@ -425,7 +425,7 @@ fn test_output_selects_columns() {
|
||||||
.args(&["--output=source"])
|
.args(&["--output=source"])
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_move_str();
|
.stdout_move_str();
|
||||||
assert_eq!(output.lines().next().unwrap(), "Filesystem");
|
assert_eq!(output.lines().next().unwrap().trim_end(), "Filesystem");
|
||||||
|
|
||||||
let output = new_ucmd!()
|
let output = new_ucmd!()
|
||||||
.args(&["--output=source,target"])
|
.args(&["--output=source,target"])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue