fix: avoid terminal wait without input (#1829)
Co-authored-by: Drew Smirnoff <drew@charm.land>
This commit is contained in:
parent
df137dee9a
commit
1b8005fc10
2 changed files with 14 additions and 2 deletions
13
exec_test.go
13
exec_test.go
|
|
@ -6,6 +6,7 @@ import (
|
|||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
type execFinishedMsg struct{ err error }
|
||||
|
|
@ -137,6 +138,18 @@ func TestTeaExecWithNilInput(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestReleaseTerminalWithNilInputDoesNotWait(t *testing.T) {
|
||||
p := NewProgram(&testExecNoInputModel{}, WithInput(nil))
|
||||
|
||||
start := time.Now()
|
||||
if err := p.ReleaseTerminal(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if elapsed := time.Since(start); elapsed >= 250*time.Millisecond {
|
||||
t.Fatalf("ReleaseTerminal took %s without an input reader", elapsed)
|
||||
}
|
||||
}
|
||||
|
||||
// execLeakModel renders a distinctive marker from View() so a test can detect
|
||||
// whether the renderer flushes the View to stdout when ExecProcess hands the
|
||||
// terminal to a subprocess. Before the fix for #431, the renderer's final
|
||||
|
|
|
|||
3
tea.go
3
tea.go
|
|
@ -1447,10 +1447,9 @@ func (p *Program) releaseTerminal(reset bool) error {
|
|||
atomic.StoreUint32(&p.ignoreSignals, 1)
|
||||
if p.cancelReader != nil {
|
||||
p.cancelReader.Cancel()
|
||||
p.waitForReadLoop()
|
||||
}
|
||||
|
||||
p.waitForReadLoop()
|
||||
|
||||
if p.renderer != nil {
|
||||
p.stopRenderer(false)
|
||||
if reset {
|
||||
|
|
|
|||
Loading…
Reference in a new issue