Commit 09744e9272eb5a8951b1fb3d8caa034ca56bdef0

Parents: 3f3f5929519195ad018b50733820ac88edc5373a

From: Robin Jarry <robin@jarry.cc>
Date: Mon Oct 30 13:06:04 2023 +0700

complete: add trailing space after quotes
Currently, completing `:tag +forw` gives: '+forwarded ' instead of
simply +forwarded without quotes with an embedded trailing space.

Add the suffix *after* quoting.

Fixes: abe228b14d97 ("commands: use completion from go-opt")
Reported-by: Inwit <inwit@sindominio.net>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Inwit <inwit@sindominio.net>

Stats

commands/util.go +2/-2

Changeset

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
diff --git a/commands/util.go b/commands/util.go
index a9aa81b3442a63af9270ead1e4409e1930199046..726669afecc86b8d96a6a2abf40312cfbbb27645 100644
--- a/commands/util.go
+++ b/commands/util.go
@@ -234,12 +234,12 @@ func FilterList(valid []string, search, prefix, suffix string, isFuzzy bool) []string {
 	out := make([]string, 0, len(valid))
 	if isFuzzy {
 		for _, v := range fuzzy.RankFindFold(search, valid) {
-			out = append(out, opt.QuoteArg(prefix+v.Target+suffix))
+			out = append(out, opt.QuoteArg(prefix+v.Target)+suffix)
 		}
 	} else {
 		for _, v := range valid {
 			if hasCaseSmartPrefix(v, search) {
-				out = append(out, opt.QuoteArg(prefix+v+suffix))
+				out = append(out, opt.QuoteArg(prefix+v)+suffix)
 			}
 		}
 	}