forked from Mirrors/bubbletea
fix: lock mutex before checking altscreen state
This prevents the odd race condition where Enter- & ExitAltScreen are called concurrently.
This commit is contained in:
parent
b8ef6f85ea
commit
db664820d4
|
@ -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()
|
||||
|
||||
|
|
Loading…
Reference in New Issue