From c07cbd1e32aeab76f7ac1eb9a621885f0b39020f Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Thu, 6 May 2021 13:48:46 -0400 Subject: [PATCH] Pull batch processing into the internal message switch --- tea.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/tea.go b/tea.go index 76d1d61..b1dfe24 100644 --- a/tea.go +++ b/tea.go @@ -422,8 +422,8 @@ func (p *Program) Start() error { return err case msg := <-msgs: - // Handle special messages - switch msg.(type) { + // Handle special internal messages + switch msg := msg.(type) { case quitMsg: p.ExitAltScreen() p.DisableMouseCellMotion() @@ -432,6 +432,12 @@ func (p *Program) Start() error { close(done) return nil + case batchMsg: + for _, cmd := range msg { + cmds <- cmd + } + continue + case enterAltScreenMsg: p.EnterAltScreen() @@ -452,14 +458,6 @@ func (p *Program) Start() error { hideCursor(p.output) } - // Process batch commands - if batchedCmds, ok := msg.(batchMsg); ok { - for _, cmd := range batchedCmds { - cmds <- cmd - } - continue - } - // Process internal messages for the renderer if r, ok := p.renderer.(*standardRenderer); ok { r.handleMessages(msg)