Skip to content

Commit

Permalink
fix: don't access output from outside renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
muesli committed Oct 4, 2022
1 parent 5d1a726 commit 21e530a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 5 additions & 5 deletions tea.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,17 +257,17 @@ func (p *Program) StartReturningModel() (Model, error) {
}()
}

// If no renderer is set use the standard one.
if p.renderer == nil {
p.renderer = newRenderer(p.output, p.startupOptions.has(withANSICompressor))
}

// Check if output is a TTY before entering raw mode, hiding the cursor and
// so on.
if err := p.initTerminal(); err != nil {
return p.initialModel, err
}

// If no renderer is set use the standard one.
if p.renderer == nil {
p.renderer = newRenderer(p.output, p.startupOptions.has(withANSICompressor))
}

// Honor program startup options.
if p.startupOptions&withAltScreen != 0 {
p.renderer.enterAltScreen()
Expand Down
6 changes: 4 additions & 2 deletions tty.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ func (p *Program) initTerminal() error {
}
}

p.output.HideCursor()
p.renderer.hideCursor()
return nil
}

// restoreTerminalState restores the terminal to the state prior to running the
// Bubble Tea program.
func (p *Program) restoreTerminalState() error {
p.output.ShowCursor()
if p.renderer != nil {
p.renderer.showCursor()
}

if p.console != nil {
err := p.console.Reset()
Expand Down

0 comments on commit 21e530a

Please sign in to comment.