Skip to content

Commit db0d170

Browse files
committed
bug fix
1 parent 474f382 commit db0d170

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

main.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,7 @@ func (t *tui) updateStdinView() {
173173
stdinCtx, stdinCancel := context.WithCancel(t.stdinPane.ctx)
174174

175175
p := t.cliPane.prompt
176-
t.cliPane.syncUpdate(func() {
177-
t.cliPane.wg.Add(1)
178-
})
179176
go func() {
180-
defer t.cliPane.wg.Done()
181177
defer stdinCancel()
182178
if p == "" {
183179
t.stdinPane.setData(stdinBytes)
@@ -187,9 +183,15 @@ func (t *tui) updateStdinView() {
187183
}()
188184
go func() {
189185
s := spinner()
186+
t.stdinPane.syncUpdate(func() {
187+
t.stdinPane.isLoading = true
188+
})
190189
for {
191190
select {
192191
case <-stdinCtx.Done():
192+
t.stdinPane.syncUpdate(func() {
193+
t.stdinPane.isLoading = false
194+
})
193195
t.QueueUpdateDraw(func() {
194196
t.stdinPane.SetTitle(t.stdinPane.name)
195197
})
@@ -208,18 +210,15 @@ func (t *tui) updateStdoutView(text string) {
208210

209211
go func() {
210212
defer stdoutCancel()
211-
t.cliPane.syncUpdate(func() {
212-
t.cliPane.wg.Wait()
213-
})
214213
t.stdinPane.syncUpdate(func() {
215214
t.QueueUpdateDraw(func() {
216-
if isBlock(text) {
215+
if isBlock(text) || t.stdinPane.isLoading {
217216
t.stdoutPane.SetTitle("no preview")
218217
} else {
219218
t.stdoutPane.SetTitle("stdout/stderr")
220219
}
221220
})
222-
if !isBlock(text) {
221+
if !isBlock(text) && !t.stdinPane.isLoading {
223222
t.stdoutPane.execCommand(stdoutCtx, text, t.stdinPane.data)
224223
}
225224
})
@@ -241,7 +240,6 @@ type cliPane struct {
241240
symbol string
242241
prompt string
243242
trimText string
244-
wg sync.WaitGroup
245243
mu sync.Mutex
246244
}
247245

@@ -336,14 +334,16 @@ func (v *viewPane) reset() {
336334

337335
type stdinViewPane struct {
338336
*viewPane
339-
data []byte
337+
data []byte
338+
isLoading bool
340339
}
341340

342341
func newStdinViewPane() *stdinViewPane {
343342
v := newViewPane("stdin")
344343
si := &stdinViewPane{
345-
viewPane: v,
346-
data: []byte(""),
344+
viewPane: v,
345+
data: []byte(""),
346+
isLoading: false,
347347
}
348348
return si
349349
}

0 commit comments

Comments
 (0)