fix: check for 0 length slice when splitting input for completions

job-suspend
sammyette 2023-02-07 15:48:59 -04:00
parent 61914f8dc7
commit f2ee600c28
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
1 changed files with 9 additions and 2 deletions

View File

@ -74,13 +74,20 @@ func splitForFile(str string) []string {
func fileComplete(query, ctx string, fields []string) ([]string, string) {
q := splitForFile(ctx)
path := ""
if len(q) != 0 {
path = q[len(q) - 1]
}
return matchPath(q[len(q) - 1])
return matchPath(path)
}
func binaryComplete(query, ctx string, fields []string) ([]string, string) {
q := splitForFile(ctx)
query = q[len(q) - 1]
query = ""
if len(q) != 0 {
query = q[len(q) - 1]
}
var completions []string