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

Spinner doesn't clean output area when printing short timestamps #374

Closed
rillig opened this issue Jun 22, 2022 · 1 comment · Fixed by #375
Closed

Spinner doesn't clean output area when printing short timestamps #374

rillig opened this issue Jun 22, 2022 · 1 comment · Fixed by #375
Assignees
Labels
bug Something isn't working

Comments

@rillig
Copy link

rillig commented Jun 22, 2022

package main

import (
	"github.com/pterm/pterm"
	"log"
	"time"
)

func main() {
	p := pterm.SpinnerPrinter{
		Text:                "text",
		Sequence:            []string{"1", "2", "3", "4"},
		Style:               pterm.GrayBoxStyle,
		Delay:               1203 * time.Millisecond,
		MessageStyle:        pterm.GrayBoxStyle,
		ShowTimer:           true,
		TimerRoundingFactor: time.Millisecond,
		TimerStyle:          pterm.GrayBoxStyle,
	}
	sp, err := p.Start("text")
	if err != nil {
		log.Fatal(err)
	}

	time.Sleep(100 * time.Minute)

	err = sp.Stop()
	if err != nil {
		log.Fatal(err)
	}
}

After running the spinner for a while, there will be a moment when the displayed time has a 0 in the last place. This trailing 0 is not displayed, making the output shorter than before. The result is:

1 text (14.441s)
4 text (27.68s))

The double )) is wrong.

@rillig rillig added the bug Something isn't working label Jun 22, 2022
@floaust
Copy link
Member

floaust commented Jun 22, 2022

You are right, seems like not the whole line gets cleared. I am on it.
Thanks for finding the bug. 👍

@floaust floaust self-assigned this Jun 22, 2022
@floaust floaust linked a pull request Jun 22, 2022 that will close this issue
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants