Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
minefuto committed Aug 19, 2024
1 parent 474f382 commit db0d170
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,7 @@ func (t *tui) updateStdinView() {
stdinCtx, stdinCancel := context.WithCancel(t.stdinPane.ctx)

p := t.cliPane.prompt
t.cliPane.syncUpdate(func() {
t.cliPane.wg.Add(1)
})
go func() {
defer t.cliPane.wg.Done()
defer stdinCancel()
if p == "" {
t.stdinPane.setData(stdinBytes)
Expand All @@ -187,9 +183,15 @@ func (t *tui) updateStdinView() {
}()
go func() {
s := spinner()
t.stdinPane.syncUpdate(func() {
t.stdinPane.isLoading = true
})
for {
select {
case <-stdinCtx.Done():
t.stdinPane.syncUpdate(func() {
t.stdinPane.isLoading = false
})
t.QueueUpdateDraw(func() {
t.stdinPane.SetTitle(t.stdinPane.name)
})
Expand All @@ -208,18 +210,15 @@ func (t *tui) updateStdoutView(text string) {

go func() {
defer stdoutCancel()
t.cliPane.syncUpdate(func() {
t.cliPane.wg.Wait()
})
t.stdinPane.syncUpdate(func() {
t.QueueUpdateDraw(func() {
if isBlock(text) {
if isBlock(text) || t.stdinPane.isLoading {
t.stdoutPane.SetTitle("no preview")
} else {
t.stdoutPane.SetTitle("stdout/stderr")
}
})
if !isBlock(text) {
if !isBlock(text) && !t.stdinPane.isLoading {
t.stdoutPane.execCommand(stdoutCtx, text, t.stdinPane.data)
}
})
Expand All @@ -241,7 +240,6 @@ type cliPane struct {
symbol string
prompt string
trimText string
wg sync.WaitGroup
mu sync.Mutex
}

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

type stdinViewPane struct {
*viewPane
data []byte
data []byte
isLoading bool
}

func newStdinViewPane() *stdinViewPane {
v := newViewPane("stdin")
si := &stdinViewPane{
viewPane: v,
data: []byte(""),
viewPane: v,
data: []byte(""),
isLoading: false,
}
return si
}
Expand Down

0 comments on commit db0d170

Please sign in to comment.