@@ -173,11 +173,7 @@ func (t *tui) updateStdinView() {
173
173
stdinCtx , stdinCancel := context .WithCancel (t .stdinPane .ctx )
174
174
175
175
p := t .cliPane .prompt
176
- t .cliPane .syncUpdate (func () {
177
- t .cliPane .wg .Add (1 )
178
- })
179
176
go func () {
180
- defer t .cliPane .wg .Done ()
181
177
defer stdinCancel ()
182
178
if p == "" {
183
179
t .stdinPane .setData (stdinBytes )
@@ -187,9 +183,15 @@ func (t *tui) updateStdinView() {
187
183
}()
188
184
go func () {
189
185
s := spinner ()
186
+ t .stdinPane .syncUpdate (func () {
187
+ t .stdinPane .isLoading = true
188
+ })
190
189
for {
191
190
select {
192
191
case <- stdinCtx .Done ():
192
+ t .stdinPane .syncUpdate (func () {
193
+ t .stdinPane .isLoading = false
194
+ })
193
195
t .QueueUpdateDraw (func () {
194
196
t .stdinPane .SetTitle (t .stdinPane .name )
195
197
})
@@ -208,18 +210,15 @@ func (t *tui) updateStdoutView(text string) {
208
210
209
211
go func () {
210
212
defer stdoutCancel ()
211
- t .cliPane .syncUpdate (func () {
212
- t .cliPane .wg .Wait ()
213
- })
214
213
t .stdinPane .syncUpdate (func () {
215
214
t .QueueUpdateDraw (func () {
216
- if isBlock (text ) {
215
+ if isBlock (text ) || t . stdinPane . isLoading {
217
216
t .stdoutPane .SetTitle ("no preview" )
218
217
} else {
219
218
t .stdoutPane .SetTitle ("stdout/stderr" )
220
219
}
221
220
})
222
- if ! isBlock (text ) {
221
+ if ! isBlock (text ) && ! t . stdinPane . isLoading {
223
222
t .stdoutPane .execCommand (stdoutCtx , text , t .stdinPane .data )
224
223
}
225
224
})
@@ -241,7 +240,6 @@ type cliPane struct {
241
240
symbol string
242
241
prompt string
243
242
trimText string
244
- wg sync.WaitGroup
245
243
mu sync.Mutex
246
244
}
247
245
@@ -336,14 +334,16 @@ func (v *viewPane) reset() {
336
334
337
335
type stdinViewPane struct {
338
336
* viewPane
339
- data []byte
337
+ data []byte
338
+ isLoading bool
340
339
}
341
340
342
341
func newStdinViewPane () * stdinViewPane {
343
342
v := newViewPane ("stdin" )
344
343
si := & stdinViewPane {
345
- viewPane : v ,
346
- data : []byte ("" ),
344
+ viewPane : v ,
345
+ data : []byte ("" ),
346
+ isLoading : false ,
347
347
}
348
348
return si
349
349
}
0 commit comments