1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2024-12-21 23:33:03 +00:00

ui/table: avoid duplicate table cell width calculation

This commit is contained in:
Michael Eischer 2024-06-07 21:45:40 +02:00
parent edd3e214c2
commit 7cd324fe26

View file

@ -141,16 +141,18 @@ func (t *Table) Write(w io.Writer) error {
columnWidths := make([]int, columns)
for i, desc := range t.columns {
for _, line := range strings.Split(desc, "\n") {
if columnWidths[i] < ui.TerminalDisplayWidth(line) {
columnWidths[i] = ui.TerminalDisplayWidth(line)
width := ui.TerminalDisplayWidth(line)
if columnWidths[i] < width {
columnWidths[i] = width
}
}
}
for _, line := range lines {
for i, content := range line {
for _, l := range strings.Split(content, "\n") {
if columnWidths[i] < ui.TerminalDisplayWidth(l) {
columnWidths[i] = ui.TerminalDisplayWidth(l)
width := ui.TerminalDisplayWidth(l)
if columnWidths[i] < width {
columnWidths[i] = width
}
}
}