vbauerster / mpb

multi progress bar for Go cli applications
The Unlicense
2.29k stars 123 forks source link

multiple pbs start acting weirdly when the length of text bigger than terminal width #70

Closed nitishgargiitd closed 4 years ago

nitishgargiitd commented 4 years ago
textReset := "\033[0m"
textRed := "\033[4;31m"
failedState := textRed + pt.Error.Error() + textReset
return progressBars.AddBar(
    1,
    mpb.BarQueueAfter(replaceBar),
    mpb.BarStyle("     "),
    mpb.BarFillerClearOnComplete(),
    mpb.PrependDecorators(
        decor.Name("Bar Name", decor.WCSyncSpaceR),
        decor.Name(failedState, decor.WCSyncSpaceR),
    ),
)

When pt.Error.Error() is big enough, it puts '...' at the end and makes the coloring goes away for that line and it messes up next lines.

To reproduce, just simply run the https://github.com/vbauerster/mpb/blob/master/_examples/complex/main.go

and make the terminal width smaller than content length, hopefully it should reproduce the bug.

Platform: Mac OS mpb version: https://github.com/vbauerster/mpb/commit/a55da8df10b6d8d8172eea63c25e65bf975806d6

vbauerster commented 4 years ago

It's expected behavior if there is no room to fit a bar in one line. I haven't seen any "messes up next lines" in example you're referring to: asciicast

If you'd like to preserve coloring or affect default truncating behavior, you have to implement custom decorator as described here.

nitishgargiitd commented 4 years ago

sorry for the delayed response, I am going to try it tomorrow and let you know how the custom decorators solution goes.