Skip to content

When reducing terminal size, bar will not remain in the same line in each rendering. Is it a bug? #106

@Andrew-M-C

Description

@Andrew-M-C
  • Device: MacBook Pro 13-inch, 2020
  • Terminal: build-in Terminal application
  • Description:
    • After the width of terminal got thinner, the previous bar remain above (which is acceptable).
    • But the new bar kept starting new lines and re-render each progress, which may not be acceptable.
    • Please refer to attached screen capture file.

source test file content:

package progress

import (
	"os"
	"testing"
	"time"

	progressbar "github.com/schollz/progressbar/v3"
	. "github.com/smartystreets/goconvey/convey"
	"golang.org/x/term"
)

func TestGeneral(t *testing.T) {
	Convey("progressbar", t, func() { testProgressbar(t) })
}

func testProgressbar(t *testing.T) {
	bar := progressbar.Default(100, "test progressbar")

	for i := 0; i < 100; i++ {
		bar.Set(i)
		time.Sleep(50 * time.Millisecond)
	}

	bar.Clear()
	w, h, err := term.GetSize(int(os.Stdout.Fd()))
	So(err, ShouldBeNil)
	t.Logf("Done, terminal size: %d x %d", w, h)
}
Screen.Recording.2021-09-02.at.10.35.14.AM.mov

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions