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.
This commit is contained in:
Dmitry Maluka 2020-05-23 20:59:23 +02:00 committed by GitHub
parent bd43a44194
commit c5b0c2d41f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View 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 {

View 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"