progressbar icon indicating copy to clipboard operation
progressbar copied to clipboard

Duplicate rendering of extra empty lines

Open zc2638 opened this issue 3 years ago • 13 comments

When revert 3e6b9bf007862f9acf97b7cdc2dc2c8f6683f110 Each time the progress bar is rendered, an empty line is added.

func main() {
	bar := progressbar.Default(100)
	for i := 0; i < 100; i++ {
		bar.Add(1)
		time.Sleep(40 * time.Millisecond)
	}
}

image

zc2638 avatar Mar 23 '21 06:03 zc2638

@schollz

zc2638 avatar Mar 23 '21 06:03 zc2638

3e6b9bf didn't fix any particular problem I knew of and caused a new problem - that progressbars that are shorter than previous are not be cleared so you get things like [0s:3s]s] at the end...

but now I see you have a particular problem that you were trying to fix. I think the fix for that problem you are having is related to the calculation of the window width used with the Default function. Can you try reducing the width here: https://github.com/schollz/progressbar/blob/master/progressbar.go#L679-L688

Also, what system are you seeing this (terminal, shell, OS, etc.)?

schollz avatar Mar 23 '21 19:03 schollz

I found that the default progress bar symbol width is uncontrollable. Apart from replacing it, how to solve it?

zc2638 avatar Mar 24 '21 05:03 zc2638

See my previous comment

schollz avatar Mar 24 '21 16:03 schollz

I haven't found a way to calculate the width of symbol. Do you have any good solution?

When I set it like this, the performance is normal:

progressbar.OptionSetTheme(progressbar.Theme{
	Saucer:        "=",
	SaucerPadding: " ",
	BarStart:      "|",
	BarEnd:        "|",
	SaucerHead:    ">",
})

zc2638 avatar Mar 26 '21 09:03 zc2638

I also encountered this problem on macOS with version v3.8.3

axetroy avatar Nov 14 '21 14:11 axetroy

macOS, v3.8.3, same problem

reber0 avatar Nov 29 '21 10:11 reber0

macOS, v3.13.0, same problem

Lan-ce-lot avatar Feb 22 '23 14:02 Lan-ce-lot

The same problem on Window10 powershell with version v3.13.1 image

JohnieXu avatar Aug 29 '23 08:08 JohnieXu

@schollz I too am having trouble with this issue. Is it correct to say that the reason for reverting 3e6b9bf is the issue where a display like [0s:3s] shown at the end of the progress bar during execution remains even after execution?

If that is correct, it seems to me that you probably have a terminal that is not working correctly because the current implementation keeps increasing s.maxLineWidth, which embeds extra space.

https://github.com/schollz/progressbar/blob/3d122971646c65a9eff62c04531ec131ffb7ce5a/progressbar.go#L990

I think that filling in the terminal with white space for the width of the terminal would solve all problems.

I created a pull request that deals with this issue. As far as I can tell from the examples/basic code, it doesn't seem to reproduce the problem, but please check just in case.

tukaelu avatar Oct 23 '23 23:10 tukaelu

I found an error in the correction, so I withdrew the pull request(#168). I finally understood that the cause of this issue lies in the part that counts the width of the symbol.

I made a fix to keep the s.maxLineWidth variable fixed at the terminal width, as I had observed it increasing as the progress bar advanced. However, it was not the correct approach.

When I set the C value for the LANG environment variable and ran it, s.maxLineWidth continued to return a fixed value. However, when I changed it to my usual setting, ja_JP.UTF-8, the issue of continuous line breaks reappeared.

This seems to be caused by the current implementation counting the number of runes.

Currently, since the library update for mattn/go-runewidth, which we use for calculating the width of runes, is lagging behind, it seems that the issue can be resolved by replacing it with rivo/uniseg that it internally uses.

tukaelu avatar Oct 25 '23 10:10 tukaelu

@zc2638 @axetroy @reber0 @Lan-ce-lot @JohnieXu

I apologize for mentioning many of you. The PR #169 that resolves this issue has been merged, and it has been released as v3.14.0.

I believe this problem has likely been resolved, so please everyone check it out.

tukaelu avatar Nov 09 '23 22:11 tukaelu

@zc2638 @axetroy @reber0 @Lan-ce-lot @JohnieXu

I apologize for mentioning many of you. The PR #169 that resolves this issue has been merged, and it has been released as v3.14.0.

I believe this problem has likely been resolved, so please everyone check it out.

I'm glad to hear that.👍

Lan-ce-lot avatar Nov 18 '23 10:11 Lan-ce-lot