feat(wip): check if lua input is incomplete

pull/59/head
sammyette 2021-05-16 15:50:49 -04:00
parent 0850247615
commit 9415c5193e
No known key found for this signature in database
GPG Key ID: 50EE40A2809851F5
1 changed files with 6 additions and 0 deletions

View File

@ -8,6 +8,7 @@ import (
"github.com/bobappleyard/readline" "github.com/bobappleyard/readline"
"github.com/yuin/gopher-lua" "github.com/yuin/gopher-lua"
"github.com/yuin/gopher-lua/parse"
"layeh.com/gopher-luar" "layeh.com/gopher-luar"
"mvdan.cc/sh/v3/interp" "mvdan.cc/sh/v3/interp"
"mvdan.cc/sh/v3/syntax" "mvdan.cc/sh/v3/syntax"
@ -31,6 +32,11 @@ func RunInput(input string) {
fn, err := l.LoadString(cmdString) fn, err := l.LoadString(cmdString)
if err != nil && noexecute { if err != nil && noexecute {
fmt.Println(err) fmt.Println(err)
if lerr, ok := err.(*lua.ApiError); ok {
if perr, ok := lerr.Cause.(*parse.Error); ok {
print(perr.Pos.Line == parse.EOF)
}
}
return return
} }
// And if there's no syntax errors and -n isnt provided, run // And if there's no syntax errors and -n isnt provided, run