fix: restore Windows console mode on shutdown

The deferred Close call on our input reader caused the console mode
to be reset twice, and the incorrect, inner mode was applied last.
This commit is contained in:
Christian Muehlhaeuser 2022-10-20 11:47:12 +02:00
parent a7067fbfa2
commit 9bcfc026a2
1 changed files with 1 additions and 1 deletions

2
tea.go
View File

@ -442,7 +442,6 @@ func (p *Program) Run() (Model, error) {
if err := p.initCancelReader(); err != nil { if err := p.initCancelReader(); err != nil {
return model, err return model, err
} }
defer p.cancelReader.Close() //nolint:errcheck
} }
// Handle resize events. // Handle resize events.
@ -468,6 +467,7 @@ func (p *Program) Run() (Model, error) {
if p.cancelReader.Cancel() { if p.cancelReader.Cancel() {
p.waitForReadLoop() p.waitForReadLoop()
} }
_ = p.cancelReader.Close()
// Wait for all handlers to finish. // Wait for all handlers to finish.
handlers.shutdown() handlers.shutdown()