From c5b0c2d41f67048ba859cbf7d7aba6a3b547e1ef Mon Sep 17 00:00:00 2001 From: Dmitry Maluka Date: Sat, 23 May 2020 20:59:23 +0200 Subject: [PATCH] Fix dropped redraw events (#1675) If screen.Redraw() is called very quickly after a key or mouse event, it may send the redraw event while micro is not waiting for it but still processing the key or mouse event. Since drawChan is non-buffered and at the same time non-blocking, this redraw event will be simply lost, so the screen content will not be up-to-date. --- cmd/micro/micro.go | 3 +++ internal/screen/screen.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/micro/micro.go b/cmd/micro/micro.go index 45e0e25b..5eb62097 100644 --- a/cmd/micro/micro.go +++ b/cmd/micro/micro.go @@ -363,6 +363,9 @@ func DoEvent() { case <-shell.CloseTerms: case event = <-events: case <-screen.DrawChan(): + for len(screen.DrawChan()) > 0 { + <-screen.DrawChan() + } } if action.InfoBar.HasPrompt { diff --git a/internal/screen/screen.go b/internal/screen/screen.go index 8eba870a..419025ea 100644 --- a/internal/screen/screen.go +++ b/internal/screen/screen.go @@ -127,7 +127,7 @@ func TempStart(screenWasNil bool) { // Init creates and initializes the tcell screen func Init() { - drawChan = make(chan bool) + drawChan = make(chan bool, 8) // Should we enable true color? truecolor := os.Getenv("MICRO_TRUECOLOR") == "1" -- 2.44.0