From 9c20a804d7761caaf312a99eb28921ffa7c92ccf Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Sun, 13 Nov 2022 23:45:57 +0100 Subject: [PATCH] fix: don't close stdin This allows programs to re-use stdin after the tea.Program has finished. Fixes #595. --- tea.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tea.go b/tea.go index 4de805e..03734bc 100644 --- a/tea.go +++ b/tea.go @@ -345,6 +345,7 @@ func (p *Program) Run() (Model, error) { if err != nil { return p.initialModel, err } + defer f.Close() //nolint:errcheck p.input = f case !p.startupOptions.has(withCustomInput): @@ -364,11 +365,8 @@ func (p *Program) Run() (Model, error) { if err != nil { return p.initialModel, err } - p.input = f - } - - if f, ok := p.input.(io.ReadCloser); ok { defer f.Close() //nolint:errcheck + p.input = f } // Handle signals.