@@ -110,10 +110,6 @@ func multiLineWrite(out io.StringWriter, prefix, lines string) {
110
110
}
111
111
112
112
func (d * display ) printState (s state , depth int ) string {
113
- if ! s .Running {
114
- return ""
115
- }
116
-
117
113
buf := & strings.Builder {}
118
114
prefix := strings .Repeat (" " , depth )
119
115
inPrefix := prefix + " |<- "
@@ -124,24 +120,34 @@ func (d *display) printState(s state, depth int) string {
124
120
if name == "" {
125
121
name = "main"
126
122
}
127
- buf .WriteString ("(running " )
123
+ if s .Running {
124
+ buf .WriteString ("(running " )
125
+ } else {
126
+ buf .WriteString ("(done " )
127
+ }
128
128
buf .WriteString (name )
129
129
buf .WriteString (")\n " )
130
130
if s .Input != "" {
131
131
multiLineWrite (buf , inPrefix , "args: " + s .Input )
132
132
}
133
133
134
+ childRunning := false
134
135
for _ , state := range d .states {
135
136
if state .Context != nil && state .Context .Parent != nil && state .Context .Parent .ID == s .Context .ID {
137
+ if state .Running {
138
+ childRunning = true
139
+ }
136
140
buf .WriteString (d .printState (state , depth + 1 ))
137
141
}
138
142
}
139
143
140
- if len (s .Input ) > 0 && len (s .Output ) > 0 {
141
- multiLineWrite (buf , outPrefix , "---" )
142
- }
144
+ if depth == 0 && ! childRunning {
145
+ if len (s .Input ) > 0 && len (s .Output ) > 0 {
146
+ multiLineWrite (buf , outPrefix , "---" )
147
+ }
143
148
144
- multiLineWrite (buf , outPrefix , s .Output )
149
+ multiLineWrite (buf , outPrefix , s .Output )
150
+ }
145
151
146
152
return buf .String ()
147
153
}
0 commit comments