ui: don't shorten non-interactive progress output

This commit is contained in:
Michael Eischer 2020-12-29 15:08:29 +01:00
parent 684600cf42
commit 023eea6463
1 changed files with 13 additions and 6 deletions

View File

@ -314,17 +314,24 @@ func (t *Terminal) SetStatus(lines []string) {
return return
} }
width, _, err := terminal.GetSize(int(t.fd)) // only truncate interactive status output
if err != nil || width <= 0 { var width int
// use 80 columns by default if t.canUpdateStatus {
width = 80 var err error
width, _, err = terminal.GetSize(int(t.fd))
if err != nil || width <= 0 {
// use 80 columns by default
width = 80
}
} }
// make sure that all lines have a line break and are not too long // make sure that all lines have a line break and are not too long
for i, line := range lines { for i, line := range lines {
line = strings.TrimRight(line, "\n") line = strings.TrimRight(line, "\n")
line = truncate(line, width-2) + "\n" if width > 0 {
lines[i] = line line = truncate(line, width-2)
}
lines[i] = line + "\n"
} }
// make sure the last line does not have a line break // make sure the last line does not have a line break