Don't call plugin if nil

This commit is contained in:
Zachary Yedidia
2020-01-28 22:06:58 -05:00
parent 953f5a0eff
commit 03228762d4
2 changed files with 7 additions and 0 deletions

View File

@@ -269,6 +269,8 @@ func main() {
action.InfoBar.Display()
screen.Screen.Show()
event = nil
// Check for new events
select {
case f := <-shell.Jobs:

View File

@@ -2,6 +2,7 @@ package config
import (
"errors"
"log"
lua "github.com/yuin/gopher-lua"
ulua "github.com/zyedidia/micro/internal/lua"
@@ -103,6 +104,10 @@ func (p *Plugin) Load() error {
func (p *Plugin) Call(fn string, args ...lua.LValue) (lua.LValue, error) {
plug := ulua.L.GetGlobal(p.Name)
if plug == lua.LNil {
log.Println("Plugin does not exist:", p.Name, "at", p.DirName, ":", p)
return nil, nil
}
luafn := ulua.L.GetField(plug, fn)
if luafn == lua.LNil {
return nil, ErrNoSuchFunction