fix: avoid terminal wait without input (#1829)

Co-authored-by: Drew Smirnoff <drew@charm.land>
This commit is contained in:
Ahmet Kamer Çivi 2026-11-12 16:32:37 +03:00 committed by GitHub
parent df137dee9a
commit 1b8005fc10
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 2 deletions

View file

@ -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
View file

@ -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 {