fix: race condition on repaint

This commit is contained in:
Georgi Dimitrov
2022-06-04 13:03:48 +01:00
committed by Christian Muehlhaeuser
parent b237b7fbec
commit 50a8461fbf

View File

@@ -230,7 +230,9 @@ func (r *standardRenderer) write(s string) {
} }
func (r *standardRenderer) repaint() { func (r *standardRenderer) repaint() {
r.mtx.Lock()
r.lastRender = "" r.lastRender = ""
r.mtx.Unlock()
} }
func (r *standardRenderer) altScreen() bool { func (r *standardRenderer) altScreen() bool {
@@ -361,9 +363,7 @@ func (r *standardRenderer) handleMessages(msg Msg) {
// Force a repaint on the area where the scrollable stuff was in this // Force a repaint on the area where the scrollable stuff was in this
// update cycle // update cycle
r.mtx.Lock() r.repaint()
r.lastRender = ""
r.mtx.Unlock()
case syncScrollAreaMsg: case syncScrollAreaMsg:
// Re-render scrolling area // Re-render scrolling area
@@ -372,9 +372,7 @@ func (r *standardRenderer) handleMessages(msg Msg) {
r.insertTop(msg.lines, msg.topBoundary, msg.bottomBoundary) r.insertTop(msg.lines, msg.topBoundary, msg.bottomBoundary)
// Force non-scrolling stuff to repaint in this update cycle // Force non-scrolling stuff to repaint in this update cycle
r.mtx.Lock() r.repaint()
r.lastRender = ""
r.mtx.Unlock()
case scrollUpMsg: case scrollUpMsg:
r.insertTop(msg.lines, msg.topBoundary, msg.bottomBoundary) r.insertTop(msg.lines, msg.topBoundary, msg.bottomBoundary)