Fixed status alignment in progress UI.

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2025-12-10 10:58:10 +01:00 committed by Nicolas De loof
parent aa9a71f37a
commit b62cbed87c

View File

@ -52,7 +52,6 @@ type ttyWriter struct {
done chan bool
mtx *sync.Mutex
dryRun bool // FIXME(ndeloof) (re)implement support for dry-run
skipChildEvents bool
operation string
ticker *time.Ticker
suspended bool
@ -234,19 +233,12 @@ func (w *ttyWriter) print() {
var statusPadding int
for _, t := range w.tasks {
l := len(t.ID)
if statusPadding < l {
if t.parentID == "" && statusPadding < l {
statusPadding = l
}
if t.parentID != "" {
statusPadding -= 2
}
}
if len(w.tasks) > goterm.Height()-2 {
w.skipChildEvents = true
}
numLines := 0
for _, id := range w.ids { // iterate on ids to enforce a consistent order
t := w.tasks[id]
if t.parentID != "" {
@ -255,16 +247,6 @@ func (w *ttyWriter) print() {
line := w.lineText(t, "", terminalWidth, statusPadding, w.dryRun)
_, _ = fmt.Fprint(w.out, line)
numLines++
for _, t := range w.tasks {
if t.parentID == t.ID {
if w.skipChildEvents {
continue
}
line := w.lineText(t, " ", terminalWidth, statusPadding, w.dryRun)
_, _ = fmt.Fprint(w.out, line)
numLines++
}
}
}
for i := numLines; i < w.numLines; i++ {
if numLines < goterm.Height()-2 {