diff --git a/standard_renderer.go b/standard_renderer.go index c0b685d..9260e5e 100644 --- a/standard_renderer.go +++ b/standard_renderer.go @@ -268,13 +268,13 @@ func (r *standardRenderer) altScreen() bool { } func (r *standardRenderer) enterAltScreen() { + r.mtx.Lock() + defer r.mtx.Unlock() + if r.altScreenActive { return } - r.mtx.Lock() - defer r.mtx.Unlock() - r.altScreenActive = true r.out.AltScreen() @@ -291,13 +291,13 @@ func (r *standardRenderer) enterAltScreen() { } func (r *standardRenderer) exitAltScreen() { + r.mtx.Lock() + defer r.mtx.Unlock() + if !r.altScreenActive { return } - r.mtx.Lock() - defer r.mtx.Unlock() - r.altScreenActive = false r.out.ExitAltScreen()