Skip to content

Commit

Permalink
fix: race condition on repaint
Browse files Browse the repository at this point in the history
  • Loading branch information
geodimm authored and muesli committed Jun 4, 2022
1 parent b237b7f commit 50a8461
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions standard_renderer.go
Expand Up @@ -230,7 +230,9 @@ func (r *standardRenderer) write(s string) {
}

func (r *standardRenderer) repaint() {
r.mtx.Lock()
r.lastRender = ""
r.mtx.Unlock()
}

func (r *standardRenderer) altScreen() bool {
Expand Down Expand Up @@ -361,9 +363,7 @@ func (r *standardRenderer) handleMessages(msg Msg) {

// Force a repaint on the area where the scrollable stuff was in this
// update cycle
r.mtx.Lock()
r.lastRender = ""
r.mtx.Unlock()
r.repaint()

case syncScrollAreaMsg:
// Re-render scrolling area
Expand All @@ -372,9 +372,7 @@ func (r *standardRenderer) handleMessages(msg Msg) {
r.insertTop(msg.lines, msg.topBoundary, msg.bottomBoundary)

// Force non-scrolling stuff to repaint in this update cycle
r.mtx.Lock()
r.lastRender = ""
r.mtx.Unlock()
r.repaint()

case scrollUpMsg:
r.insertTop(msg.lines, msg.topBoundary, msg.bottomBoundary)
Expand Down

0 comments on commit 50a8461

Please sign in to comment.