Commit c4e6de9d59cc534171fd0ef9fa51995e70a8b32e

Parents: 2dfeb7130a8fb97d927a55efa738f110f46cb688

From: Robin Jarry <robin@jarry.cc>
Date: Mon Oct 30 20:45:57 2023 +0700

cf: do not quote notmuch queries in completion results
Notmuch queries should not be quoted, they will be interpreted by the
notmuch library. Make sure not to return quoted results for directories
which have the role == "query".

Reported-by: Inwit <inwit@sindominio.net>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Inwit <inwit@sindominio.net>

Stats

commands/account/cf.go +15/-1

Changeset

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
diff --git a/commands/account/cf.go b/commands/account/cf.go
index fe225e6184cdc30e5841dc6b4937be098b3e39f6..d8d615aada558c26caf56f7fca8311a65d31489e 100644
--- a/commands/account/cf.go
+++ b/commands/account/cf.go
@@ -7,6 +7,7 @@
 	"git.sr.ht/~rjarry/aerc/app"
 	"git.sr.ht/~rjarry/aerc/commands"
 	"git.sr.ht/~rjarry/aerc/lib/state"
+	"git.sr.ht/~rjarry/aerc/models"
 	"git.sr.ht/~rjarry/aerc/worker/handlers"
 	"git.sr.ht/~rjarry/aerc/worker/types"
 	"git.sr.ht/~rjarry/go-opt"
@@ -28,7 +29,20 @@ 	return []string{"cf"}
 }
 
 func (*ChangeFolder) CompleteFolder(arg string) []string {
-	return commands.GetFolders(arg)
+	acct := app.SelectedAccount()
+	if acct == nil {
+		return nil
+	}
+	return commands.FilterList(
+		acct.Directories().List(), arg,
+		func(s string) string {
+			dir := acct.Directories().Directory(s)
+			if dir != nil && dir.Role != models.QueryRole {
+				s = opt.QuoteArg(s)
+			}
+			return s
+		},
+	)
 }
 
 func (c ChangeFolder) Execute(args []string) error {