diff --git a/internal/ui/table/table.go b/internal/ui/table/table.go index ae09063be..0423ddb48 100644 --- a/internal/ui/table/table.go +++ b/internal/ui/table/table.go @@ -142,7 +142,7 @@ func (t *Table) Write(w io.Writer) error { for i, desc := range t.columns { for _, line := range strings.Split(desc, "\n") { if columnWidths[i] < ui.TerminalDisplayWidth(line) { - columnWidths[i] = ui.TerminalDisplayWidth(desc) + columnWidths[i] = ui.TerminalDisplayWidth(line) } } } diff --git a/internal/ui/table/table_test.go b/internal/ui/table/table_test.go index 7a94b7f9b..2902860b9 100644 --- a/internal/ui/table/table_test.go +++ b/internal/ui/table/table_test.go @@ -29,6 +29,21 @@ first column ---------------------- data: first data field ---------------------- +`, + }, + { + func(t testing.TB) *Table { + table := New() + table.AddColumn("first\ncolumn", "{{.First}}") + table.AddRow(struct{ First string }{"data"}) + return table + }, + ` +first +column +------ +data +------ `, }, {