Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to leave progress bar visible after finished #75

Open
vsekhar opened this issue Sep 28, 2020 · 13 comments
Open

Option to leave progress bar visible after finished #75

vsekhar opened this issue Sep 28, 2020 · 13 comments

Comments

@vsekhar
Copy link

vsekhar commented Sep 28, 2020

Option to leave progress bar onscreen when finished. Useful for seeing counts and rates after completing a run.

@schollz
Copy link
Owner

schollz commented Sep 29, 2020

Great! Would happily accept PR with this

@ibraimgm
Copy link

Can I try this one for hacktoberfest?

@schollz
Copy link
Owner

schollz commented Sep 30, 2020

@ibraimgm of course!

@ibraimgm
Copy link

ibraimgm commented Oct 4, 2020

@vsekhar can you giv me more details or a demo where I can better understand your problem? On all the demos, the progress bar remain visible after the run.

@shadowspore
Copy link
Contributor

Wait, but...

func OptionClearOnFinish() Option {

@michaeltintiuc
Copy link

Confirming that progressbar.Default(100) keeps the progress bar visible on completion and the below hides it.

	bar := progressbar.NewOptions(100,
		progressbar.OptionClearOnFinish(),
	)

@ibraimgm
Copy link

ibraimgm commented Oct 4, 2020

@vsekhar Does this solve your issue?

@vsekhar
Copy link
Author

vsekhar commented Oct 5, 2020

If my program logs after the bar finishes, then depending on the cursor and output stream (I use go-ansi), the bar either disappears or gets merged/garbled with the next log message.

I think the issue is a lack of newline once the bar finishes. I think you need something like

if !p.config.clearOnFinish {
  if _, err := io.WriteString(c.writer, "\n"); err != nil {
    return err
  }
}

inserted here.

@vidu171
Copy link

vidu171 commented Oct 13, 2020

Is this issue still open?. If it is can I pick it up?

@schollz
Copy link
Owner

schollz commented Oct 13, 2020

@vidu171 Its open, go ahead!

@vidu171
Copy link

vidu171 commented Oct 14, 2020

Hi, I am not able to recreate this issue my bar is still visible after and it doesn't get merged/garbled with the next log message.
Can you please tell me the steps or sample code to recreate this issue?

@janpfeifer
Copy link
Contributor

I was also having this issue, it seems the problem happens with p.config.userANSICodes is set to true only, since it clears the line after it was re-rendered for finish.

I think simple removing lines 628-633 should solve the issue:

https://github.com/schollz/progressbar/blob/master/progressbar.go#L628

Notice that when not using ANSI Codes, the clearing happen before teh re-rendering, here:

https://github.com/schollz/progressbar/blob/master/progressbar.go#L609

@janpfeifer
Copy link
Contributor

Simple 0.5 line fix, at least for the case with config.useANSICodes: #140

schollz added a commit that referenced this issue Oct 22, 2022
Fixes case where bar was being incorrectly cleared on finished #75
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants