Skip to content

Commit

Permalink
fix: don't close stdin
Browse files Browse the repository at this point in the history
This allows programs to re-use stdin after the tea.Program has
finished.

Fixes #595.
  • Loading branch information
muesli committed Nov 13, 2022
1 parent e079831 commit 9c20a80
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions tea.go
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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.
Expand Down

0 comments on commit 9c20a80

Please sign in to comment.