diff --git a/cmd/restic/progress.go b/cmd/restic/progress.go index 48aa209a6..d9ff634ce 100644 --- a/cmd/restic/progress.go +++ b/cmd/restic/progress.go @@ -53,7 +53,7 @@ func newGenericProgressMax(show bool, max uint64, description string, print func func newTerminalProgressMax(show bool, max uint64, description string, term *termstatus.Terminal) *progress.Counter { return newGenericProgressMax(show, max, description, func(status string, final bool) { if final { - term.SetStatus([]string{}) + term.SetStatus(nil) term.Print(status) } else { term.SetStatus([]string{status}) diff --git a/internal/ui/backup/text.go b/internal/ui/backup/text.go index 43e963b82..f96746739 100644 --- a/internal/ui/backup/text.go +++ b/internal/ui/backup/text.go @@ -121,7 +121,7 @@ func (b *TextProgress) ReportTotal(start time.Time, s archiver.ScanStats) { // Reset status func (b *TextProgress) Reset() { if b.term.CanUpdateStatus() { - b.term.SetStatus([]string{""}) + b.term.SetStatus(nil) } } diff --git a/internal/ui/restore/text.go b/internal/ui/restore/text.go index 2f0b3c01f..235e7f085 100644 --- a/internal/ui/restore/text.go +++ b/internal/ui/restore/text.go @@ -62,7 +62,7 @@ func (t *textPrinter) CompleteItem(messageType ItemAction, item string, size uin } func (t *textPrinter) Finish(p State, duration time.Duration) { - t.terminal.SetStatus([]string{}) + t.terminal.SetStatus(nil) timeLeft := ui.FormatDuration(duration) formattedAllBytesTotal := ui.FormatBytes(p.AllBytesTotal) diff --git a/internal/ui/termstatus/status.go b/internal/ui/termstatus/status.go index 4a73ce5b3..39654cc8c 100644 --- a/internal/ui/termstatus/status.go +++ b/internal/ui/termstatus/status.go @@ -315,11 +315,8 @@ func sanitizeLines(lines []string, width int) []string { // SetStatus updates the status lines. // The lines should not contain newlines; this method adds them. +// Pass nil or an empty array to remove the status lines. func (t *Terminal) SetStatus(lines []string) { - if len(lines) == 0 { - return - } - // only truncate interactive status output var width int if t.canUpdateStatus { diff --git a/internal/ui/termstatus/status_test.go b/internal/ui/termstatus/status_test.go index 997a2d7b1..2a17a905a 100644 --- a/internal/ui/termstatus/status_test.go +++ b/internal/ui/termstatus/status_test.go @@ -32,6 +32,15 @@ func TestSetStatus(t *testing.T) { term.SetStatus([]string{"first"}) exp := home + clear + "first" + home + term.SetStatus([]string{""}) + exp += home + clear + "" + home + + term.SetStatus([]string{}) + exp += home + clear + "" + home + + // already empty status + term.SetStatus([]string{}) + term.SetStatus([]string{"foo", "bar", "baz"}) exp += home + clear + "foo\n" + home + clear + "bar\n" + home + clear + "baz" + home + up + up