Skip to content

Commit

Permalink
consider total row in column width computation
Browse files Browse the repository at this point in the history
  • Loading branch information
cre4ture committed Mar 15, 2024
1 parent 018758c commit 667f5c3
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/uu/df/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,12 +395,6 @@ impl Table {
let values = fmt.get_values();
total += row;

for (i, value) in values.iter().enumerate() {
if UnicodeWidthStr::width(value.as_str()) > widths[i] {
widths[i] = UnicodeWidthStr::width(value.as_str());
}
}

rows.push(values);
}
}
Expand All @@ -410,6 +404,14 @@ impl Table {
rows.push(total_row.get_values());
}

for row in &rows {
for (i, value) in row.iter().enumerate() {
if UnicodeWidthStr::width(value.as_str()) > widths[i] {
widths[i] = UnicodeWidthStr::width(value.as_str());
}
}
}

Self {
rows,
widths,
Expand Down

0 comments on commit 667f5c3

Please sign in to comment.