fix: only try to run hinter function if it isnt nil

pull/128/head
TorchedSammy 2022-03-26 18:24:49 -04:00
parent 6ea25a22b3
commit 0cad0e7e66
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
1 changed files with 5 additions and 1 deletions

6
rl.go
View File

@ -13,7 +13,7 @@ type lineReader struct {
rl *readline.Instance rl *readline.Instance
} }
var fileHist *fileHistory var fileHist *fileHistory
var hinter lua.LValue var hinter lua.LValue = lua.LNil
// other gophers might hate this naming but this is local, shut up // other gophers might hate this naming but this is local, shut up
func newLineReader(prompt string, noHist bool) *lineReader { func newLineReader(prompt string, noHist bool) *lineReader {
@ -46,6 +46,10 @@ func newLineReader(prompt string, noHist bool) *lineReader {
hooks.Em.Emit("hilbish.vimAction", actionStr, args) hooks.Em.Emit("hilbish.vimAction", actionStr, args)
} }
rl.HintText = func(line []rune, pos int) []rune { rl.HintText = func(line []rune, pos int) []rune {
if hinter == lua.LNil {
return []rune{}
}
err := l.CallByParam(lua.P{ err := l.CallByParam(lua.P{
Fn: hinter, Fn: hinter,
NRet: 1, NRet: 1,