From ebec5856904e5f5b6c8b88045c27afab23d5bad8 Mon Sep 17 00:00:00 2001 From: TorchedSammy <38820196+TorchedSammy@users.noreply.github.com> Date: Fri, 25 Nov 2022 19:35:26 -0400 Subject: [PATCH] fix: binary completion with spaces (closes #210) --- complete.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/complete.go b/complete.go index 7c5153f..99da07f 100644 --- a/complete.go +++ b/complete.go @@ -79,6 +79,9 @@ func fileComplete(query, ctx string, fields []string) ([]string, string) { } func binaryComplete(query, ctx string, fields []string) ([]string, string) { + q := splitForFile(ctx) + query = q[len(q) - 1] + var completions []string prefixes := []string{"./", "../", "/", "~/"} @@ -88,7 +91,7 @@ func binaryComplete(query, ctx string, fields []string) ([]string, string) { if len(fileCompletions) != 0 { for _, f := range fileCompletions { fullPath, _ := filepath.Abs(util.ExpandHome(query + strings.TrimPrefix(f, filePref))) - if err := findExecutable(fullPath, false, true); err != nil { + if err := findExecutable(escapeInvertReplaer.Replace(fullPath), false, true); err != nil { continue } completions = append(completions, f)