From f2ee600c280097f336609fbd0e9e16d47a3be899 Mon Sep 17 00:00:00 2001 From: sammyette Date: Tue, 7 Feb 2023 15:48:59 -0400 Subject: [PATCH] fix: check for 0 length slice when splitting input for completions --- complete.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/complete.go b/complete.go index f6348a8..3850c65 100644 --- a/complete.go +++ b/complete.go @@ -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