Skip to content

Commit b62cbed

Browse files
committed
Fixed status alignment in progress UI.
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent aa9a71f commit b62cbed

File tree

1 file changed

+13
-31
lines changed

1 file changed

+13
-31
lines changed

cmd/display/tty.go

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,18 @@ func Full(out io.Writer, info io.Writer) api.EventProcessor {
4444
}
4545

4646
type ttyWriter struct {
47-
out io.Writer
48-
ids []string // tasks ids ordered as first event appeared
49-
tasks map[string]task
50-
repeated bool
51-
numLines int
52-
done chan bool
53-
mtx *sync.Mutex
54-
dryRun bool // FIXME(ndeloof) (re)implement support for dry-run
55-
skipChildEvents bool
56-
operation string
57-
ticker *time.Ticker
58-
suspended bool
59-
info io.Writer
47+
out io.Writer
48+
ids []string // tasks ids ordered as first event appeared
49+
tasks map[string]task
50+
repeated bool
51+
numLines int
52+
done chan bool
53+
mtx *sync.Mutex
54+
dryRun bool // FIXME(ndeloof) (re)implement support for dry-run
55+
operation string
56+
ticker *time.Ticker
57+
suspended bool
58+
info io.Writer
6059
}
6160

6261
type task struct {
@@ -234,19 +233,12 @@ func (w *ttyWriter) print() {
234233
var statusPadding int
235234
for _, t := range w.tasks {
236235
l := len(t.ID)
237-
if statusPadding < l {
236+
if t.parentID == "" && statusPadding < l {
238237
statusPadding = l
239238
}
240-
if t.parentID != "" {
241-
statusPadding -= 2
242-
}
243239
}
244240

245-
if len(w.tasks) > goterm.Height()-2 {
246-
w.skipChildEvents = true
247-
}
248241
numLines := 0
249-
250242
for _, id := range w.ids { // iterate on ids to enforce a consistent order
251243
t := w.tasks[id]
252244
if t.parentID != "" {
@@ -255,16 +247,6 @@ func (w *ttyWriter) print() {
255247
line := w.lineText(t, "", terminalWidth, statusPadding, w.dryRun)
256248
_, _ = fmt.Fprint(w.out, line)
257249
numLines++
258-
for _, t := range w.tasks {
259-
if t.parentID == t.ID {
260-
if w.skipChildEvents {
261-
continue
262-
}
263-
line := w.lineText(t, " ", terminalWidth, statusPadding, w.dryRun)
264-
_, _ = fmt.Fprint(w.out, line)
265-
numLines++
266-
}
267-
}
268250
}
269251
for i := numLines; i < w.numLines; i++ {
270252
if numLines < goterm.Height()-2 {

0 commit comments

Comments
 (0)