diff --git a/bar_filler_bar.go b/bar_filler_bar.go index b27619d..5f89276 100644 --- a/bar_filler_bar.go +++ b/bar_filler_bar.go @@ -101,11 +101,11 @@ func (s *barFiller) Fill(w io.Writer, reqWidth int, stat decor.Statistics) { width := internal.CalcWidthForBarFiller(reqWidth, stat.AvailableWidth) - // don't count rLeft and rRight as progress - brackets := s.rwidth[rLeft] + s.rwidth[rRight] - width -= brackets - if width < brackets { + if brackets := s.rwidth[rLeft] + s.rwidth[rRight]; width < brackets { return + } else { + // don't count brackets as progress + width -= brackets } w.Write(s.format[rLeft]) defer w.Write(s.format[rRight]) diff --git a/draw_test.go b/draw_test.go index 43f0477..c9f245a 100644 --- a/draw_test.go +++ b/draw_test.go @@ -64,7 +64,7 @@ current: 20, barWidth: 80, trimSpace: true, - want: "", + want: "[]", }, }, 3: { @@ -81,7 +81,7 @@ current: 20, barWidth: 80, trimSpace: true, - want: "", + want: "[-]", }, }, 4: { @@ -90,7 +90,7 @@ total: 60, current: 20, barWidth: 80, - want: " ", + want: " [] ", }, { name: "t,c,bw{60,20,80}trim", @@ -107,7 +107,7 @@ total: 60, current: 20, barWidth: 80, - want: " ", + want: " [-] ", }, { name: "t,c,bw{60,20,80}trim",