diff --git a/bar_filler_bar.go b/bar_filler_bar.go index 82afd2c..77c1b03 100644 --- a/bar_filler_bar.go +++ b/bar_filler_bar.go @@ -150,9 +150,8 @@ func (s *bFiller) Fill(w io.Writer, stat decor.Statistics) (err error) { width := internal.CheckRequestedWidth(stat.RequestedWidth, stat.AvailableWidth) - brackets := s.components[iLbound].width + s.components[iRbound].width // don't count brackets as progress - width -= brackets + width -= (s.components[iLbound].width + s.components[iRbound].width) if width < 0 { return nil } @@ -161,14 +160,10 @@ if err != nil { return err } - defer func() { - if err == nil { - _, err = w.Write(s.components[iRbound].bytes) - } - }() if width == 0 { - return nil + _, err = w.Write(s.components[iRbound].bytes) + return err } var filling [][]byte @@ -237,9 +232,14 @@ } if s.rev { - return flush(w, padding, filling) - } - return flush(w, filling, padding) + filling, padding = padding, filling + } + err = flush(w, filling, padding) + if err != nil { + return err + } + _, err = w.Write(s.components[iRbound].bytes) + return err } func flush(w io.Writer, filling, padding [][]byte) error {