mirror of https://github.com/restic/restic.git
ui/table: fix width calculation of multi-line column headers
This commit is contained in:
parent
e9de9684f4
commit
edd3e214c2
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
------
|
||||
`,
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue