]> git.lizzy.rs Git - micro.git/commitdiff
Fix dropped redraw events (#1675) v2.0.4
authorDmitry Maluka <dmitrymaluka@gmail.com>
Sat, 23 May 2020 18:59:23 +0000 (20:59 +0200)
committerGitHub <noreply@github.com>
Sat, 23 May 2020 18:59:23 +0000 (14:59 -0400)
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
internal/screen/screen.go

index 45e0e25bffbff332bedeea4cbaef1c8d03710f3a..5eb62097192419c5b830c78483312ed2a7878f50 100644 (file)
@@ -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 {
index 8eba870a2025cab212ab49eff94469ab4d69cba0..419025ead1984fd361ed5dc8008485ffa9a79792 100644 (file)
@@ -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"