mirror of
https://github.com/taigrr/bubbletea.git
synced 2026-04-02 02:59:09 -07:00
fix: lock mutex before checking altscreen state
This prevents the odd race condition where Enter- & ExitAltScreen are called concurrently.
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user