Only lock event handling

This commit is contained in:
Zachary Yedidia 2020-06-28 16:34:01 -04:00
parent 253281ae5e
commit b8fbbf5c83

View file

@ -345,9 +345,7 @@ func main() {
// okay to be inefficient and run it via a function every time // okay to be inefficient and run it via a function every time
// We do this so we can recover from panics without crashing the editor // We do this so we can recover from panics without crashing the editor
for { for {
ulua.Lock.Lock()
DoEvent() DoEvent()
ulua.Lock.Unlock()
} }
} }
@ -380,11 +378,15 @@ func DoEvent() {
select { select {
case f := <-shell.Jobs: case f := <-shell.Jobs:
// If a new job has finished while running in the background we should execute the callback // If a new job has finished while running in the background we should execute the callback
ulua.Lock.Lock()
f.Function(f.Output, f.Args) f.Function(f.Output, f.Args)
ulua.Lock.Unlock()
case <-config.Autosave: case <-config.Autosave:
ulua.Lock.Lock()
for _, b := range buffer.OpenBuffers { for _, b := range buffer.OpenBuffers {
b.Save() b.Save()
} }
ulua.Lock.Unlock()
case <-shell.CloseTerms: case <-shell.CloseTerms:
case event = <-events: case event = <-events:
case <-screen.DrawChan(): case <-screen.DrawChan():
@ -393,9 +395,11 @@ func DoEvent() {
} }
} }
ulua.Lock.Lock()
if action.InfoBar.HasPrompt { if action.InfoBar.HasPrompt {
action.InfoBar.HandleEvent(event) action.InfoBar.HandleEvent(event)
} else { } else {
action.Tabs.HandleEvent(event) action.Tabs.HandleEvent(event)
} }
ulua.Lock.Unlock()
} }