From 023eea64634b074016eec73005341b4bce95da13 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Tue, 29 Dec 2020 15:08:29 +0100 Subject: [PATCH] ui: don't shorten non-interactive progress output --- internal/ui/termstatus/status.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/internal/ui/termstatus/status.go b/internal/ui/termstatus/status.go index ff0a899f6..30fe47f01 100644 --- a/internal/ui/termstatus/status.go +++ b/internal/ui/termstatus/status.go @@ -314,17 +314,24 @@ func (t *Terminal) SetStatus(lines []string) { return } - width, _, err := terminal.GetSize(int(t.fd)) - if err != nil || width <= 0 { - // use 80 columns by default - width = 80 + // only truncate interactive status output + var width int + if t.canUpdateStatus { + 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 for i, line := range lines { line = strings.TrimRight(line, "\n") - line = truncate(line, width-2) + "\n" - lines[i] = line + if width > 0 { + line = truncate(line, width-2) + } + lines[i] = line + "\n" } // make sure the last line does not have a line break