From: Zachary Yedidia Date: Wed, 12 Feb 2020 01:03:32 +0000 (-0500) Subject: Don't block when redraw channel becomes full X-Git-Tag: v2.0.1~16 X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=82240370806ab37a0c38fe287ad1e1f847d4e4bb;p=micro.git Don't block when redraw channel becomes full Fixes #1497 --- diff --git a/internal/action/actions.go b/internal/action/actions.go index 51c7ae95..fdef717a 100644 --- a/internal/action/actions.go +++ b/internal/action/actions.go @@ -1220,7 +1220,7 @@ func (h *BufPane) ToggleDiffGutter() bool { if !h.Buf.Settings["diffgutter"].(bool) { h.Buf.Settings["diffgutter"] = true h.Buf.UpdateDiff(func(synchronous bool) { - screen.DrawChan <- true + screen.Redraw() }) InfoBar.Message("Enabled diff gutter") } else { diff --git a/internal/buffer/buffer.go b/internal/buffer/buffer.go index a57a228b..c3b8fa85 100644 --- a/internal/buffer/buffer.go +++ b/internal/buffer/buffer.go @@ -644,7 +644,7 @@ func (b *Buffer) UpdateRules() { go func() { b.Highlighter.HighlightStates(b) b.Highlighter.HighlightMatches(b, 0, b.End().Y) - screen.DrawChan <- true + screen.Redraw() }() } } @@ -1033,7 +1033,7 @@ func (b *Buffer) SetDiffBase(diffBase []byte) { b.diffBaseLineCount = strings.Count(string(diffBase), "\n") } b.UpdateDiff(func(synchronous bool) { - screen.DrawChan <- true + screen.Redraw() }) } diff --git a/internal/config/runtime.go b/internal/config/runtime.go index 303aa3f4..4c3f8e14 100644 --- a/internal/config/runtime.go +++ b/internal/config/runtime.go @@ -1058,7 +1058,7 @@ func runtimePluginsCommentHelpCommentMd() (*asset, error) { return a, nil } -var _runtimePluginsDiffDiffLua = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x64\x50\xbd\x6e\x83\x30\x10\x9e\xf1\x53\x9c\x3c\x81\x44\x9c\x74\x8d\xc4\x90\x3f\xa9\x5d\x92\xaa\x54\x5d\x2b\xc7\x9c\x8b\x55\xb0\x11\x3e\xd4\x64\xc9\xb3\x57\x76\x81\xa6\xea\x00\xb6\xbf\xfb\xfe\x74\x6f\x87\x97\xf2\xe9\x74\x84\x02\xf8\x83\x58\x89\x15\x67\xac\x71\x4a\x36\xe0\x3c\x14\x60\xda\xce\xf5\x94\x72\xe7\x79\x36\xe2\xda\x34\xd8\x49\xaa\xef\xa6\xe1\xb9\x9c\xf0\x99\xe8\x6b\x6c\x9a\x3b\x56\x6b\x54\xef\x96\x11\xe5\x19\x63\x7a\xb0\x8a\x8c\xb3\xe0\xec\x76\xd0\x1a\xfb\x53\x87\x36\x3d\x0f\x3a\x63\x89\xd1\x90\x5a\x47\x70\x1e\xb4\x78\xbd\x76\x28\x4a\xd5\x4b\x52\x75\x06\xd2\x56\x10\x48\xe2\x39\x54\xb8\x15\xc0\x79\x06\x54\xa3\x65\x49\xb2\x58\x80\xaa\x51\x7d\x02\xd5\x92\x62\x4f\xc0\x8b\xf1\xe4\x59\x92\xfc\x54\x7a\xcf\x01\xfb\x1e\x0a\x70\x5e\x94\x24\x29\x3a\x6d\xce\x3e\x98\x65\x2c\x09\xb9\x71\x5e\x80\x35\xcd\x64\x3b\x6a\x2b\xd3\x1f\x65\x8b\x79\x34\x0e\x37\x28\xe6\x5d\x88\xb2\x6b\xcc\x3f\xb7\x59\xa8\xf5\x56\x7a\x9c\xb2\xe3\x06\xc4\xe1\x82\x6a\xe7\xda\x56\xda\x2a\xe5\x1f\x86\x78\x0e\x7c\xb1\xe3\xf9\x6f\x0e\xf7\xb5\xfb\x0a\xf0\xe3\x61\xb3\x5f\x8b\x25\x07\x21\xe6\xf0\xe8\x3f\xd6\xbd\xfd\xad\x9b\x4c\x81\x50\x84\x05\xae\xb7\x57\x42\x9f\x46\x01\xda\x2a\x1c\x01\x2d\x91\xf6\x23\x2f\x9d\x04\x81\x13\x29\xe1\x17\xbe\xef\x00\x00\x00\xff\xff\x22\xd9\xda\xfa\x1d\x02\x00\x00" +var _runtimePluginsDiffDiffLua = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x64\x50\x3b\x0b\xdb\x30\x10\x9e\xad\x5f\x71\x68\xb2\xc1\x51\xd2\x35\xe0\x21\x2f\x68\x97\xa4\xd4\xa5\x4b\x29\x45\x91\x4f\xb1\xa8\x2d\x19\xe9\x4c\x93\x25\xbf\xbd\x48\xb1\xdd\x94\x0e\x7e\xe8\xbb\xef\xa5\xfb\x76\xfa\x52\x7f\xba\x9c\xa1\x02\xfe\x41\x6c\xc4\x86\x33\xd6\x39\x25\x3b\x70\x01\x2a\x30\xfd\xe0\x3c\xe5\xdc\x05\x5e\x4c\xb8\x36\x1d\x0e\x92\xda\xb7\x69\x3c\xae\x67\x7c\x21\x86\x16\xbb\xee\x8d\xd5\x1b\xe5\xdd\x3a\xa1\xbc\x60\x4c\x8f\x56\x91\x71\x16\x9c\xdd\x8f\x5a\xa3\xbf\x0c\x68\xf3\xeb\xa8\x0b\x96\x19\x0d\xd7\x51\x8b\x1a\x89\x8c\xbd\x85\xef\xbc\x31\x5a\xdf\x46\x22\xf4\xfc\x07\x48\xdb\x40\x6e\x1d\x25\xce\xd7\xc7\x80\xa2\x56\x5e\x92\x6a\x8b\xd7\x28\xc2\x9f\x63\xc3\x67\x05\x9c\x17\x40\x2d\x5a\x96\x65\xab\x15\xa8\x16\xd5\x2f\xa0\x56\x52\xba\x06\xe0\xdd\x04\x0a\x2c\xcb\x5e\x8d\x7f\x96\x80\xde\x43\x05\x2e\x88\x9a\x24\x25\xa7\xdd\x35\x44\xb3\x82\x65\xb1\x56\x9a\x57\x60\x4d\x37\xdb\x4e\xda\xc6\xf8\xb3\xec\xb1\x4c\xc6\xf1\x0f\xaa\x65\x55\xa2\x1e\x3a\xf3\x9f\xdb\x22\xd4\x7a\x2f\x03\xce\xd9\x69\x41\xe2\x74\x47\x75\x70\x7d\x2f\x6d\x93\xf3\x9b\x21\x5e\x02\x5f\x1d\x78\xf9\x37\x87\x87\xd6\xfd\x8e\xf0\xc7\xd3\xee\xb8\x15\x6b\x0e\x42\x2c\xe1\xc9\x7f\xaa\xfb\xfc\xb7\x6e\x36\x07\x42\x15\x17\xb8\xdd\x3f\x08\x43\x9e\x04\x68\x9b\xf8\x89\x68\x8d\x74\x9c\x78\xf9\x2c\x88\x9c\x44\x89\xaf\xf8\xfc\x09\x00\x00\xff\xff\x92\x87\x8a\x37\x3c\x02\x00\x00" func runtimePluginsDiffDiffLuaBytes() ([]byte, error) { return bindataRead( diff --git a/internal/display/bufwindow.go b/internal/display/bufwindow.go index b7c94632..4f0e425c 100644 --- a/internal/display/bufwindow.go +++ b/internal/display/bufwindow.go @@ -430,7 +430,7 @@ func (w *BufWindow) displayBuffer() { // be another call to UpdateDiff when displayBuffer is called // during the redraw. if !synchronous { - screen.DrawChan <- true + screen.Redraw() } }) } diff --git a/internal/screen/screen.go b/internal/screen/screen.go index f9ab1bd8..f601af1c 100644 --- a/internal/screen/screen.go +++ b/internal/screen/screen.go @@ -37,7 +37,11 @@ func Unlock() { // Redraw schedules a redraw with the draw channel func Redraw() { - DrawChan <- true + select { + case DrawChan <- true: + default: + // channel is full + } } type screenCell struct { @@ -118,7 +122,7 @@ func TempStart(screenWasNil bool) { // Init creates and initializes the tcell screen func Init() { - DrawChan = make(chan bool, 8) + DrawChan = make(chan bool) // Should we enable true color? truecolor := os.Getenv("MICRO_TRUECOLOR") == "1" diff --git a/runtime/plugins/diff/diff.lua b/runtime/plugins/diff/diff.lua index ca9f8b70..f64d8a78 100644 --- a/runtime/plugins/diff/diff.lua +++ b/runtime/plugins/diff/diff.lua @@ -5,7 +5,7 @@ local filepath = import("path/filepath") local shell = import("micro/shell") function onBufferOpen(buf) - if (not buf.Type.Scratch) and (buf.Path ~= "") then + if buf.Settings["diffgutter"] and (not buf.Type.Scratch) and (buf.Path ~= "") then -- check that file exists local _, err = os.Stat(buf.AbsPath) if err == nil then