aboutsummaryrefslogtreecommitdiffstats
path: root/commands/account
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-10-30 21:05:56 +0100
committerRobin Jarry <robin@jarry.cc>2023-11-02 11:59:39 +0100
commit2dfeb7130a8fb97d927a55efa738f110f46cb688 (patch)
treecca6a06999d2be32f01e4ac6ae2998c5f24c2895 /commands/account
parentfaa879f9a84d44f9b251410fc923a827a44df1a7 (diff)
downloadaerc-2dfeb7130a8fb97d927a55efa738f110f46cb688.tar.gz
completion: refactor filter list api
Remove CompletionFromList which is a trivial wrapper around FilterList. Remove the prefix, suffix and isFuzzy arguments from FilterList. Replace prefix, suffix by an optional callback to allow post processing of completion results before presenting them to the user. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Inwit <inwit@sindominio.net>
Diffstat (limited to 'commands/account')
-rw-r--r--commands/account/mkdir.go10
-rw-r--r--commands/account/recover.go2
-rw-r--r--commands/account/search.go6
-rw-r--r--commands/account/sort.go2
4 files changed, 12 insertions, 8 deletions
diff --git a/commands/account/mkdir.go b/commands/account/mkdir.go
index 3e546ace..af3d1045 100644
--- a/commands/account/mkdir.go
+++ b/commands/account/mkdir.go
@@ -7,6 +7,7 @@ import (
"git.sr.ht/~rjarry/aerc/app"
"git.sr.ht/~rjarry/aerc/commands"
"git.sr.ht/~rjarry/aerc/worker/types"
+ "git.sr.ht/~rjarry/go-opt"
)
type MakeDir struct {
@@ -26,10 +27,13 @@ func (*MakeDir) CompleteFolder(arg string) []string {
if acct == nil {
return nil
}
+ sep := app.SelectedAccount().Worker().PathSeparator()
return commands.FilterList(
- acct.Directories().List(), arg, "",
- app.SelectedAccount().Worker().PathSeparator(),
- app.SelectedAccountUiConfig().FuzzyComplete)
+ acct.Directories().List(), arg,
+ func(s string) string {
+ return opt.QuoteArg(s) + sep
+ },
+ )
}
func (m MakeDir) Execute(args []string) error {
diff --git a/commands/account/recover.go b/commands/account/recover.go
index cba6e0cb..a2170edd 100644
--- a/commands/account/recover.go
+++ b/commands/account/recover.go
@@ -39,7 +39,7 @@ func (*Recover) CompleteFile(arg string) []string {
if err != nil {
return nil
}
- return commands.CompletionFromList(files, arg)
+ return commands.FilterList(files, arg, nil)
}
func (r Recover) Execute(args []string) error {
diff --git a/commands/account/search.go b/commands/account/search.go
index ca1b9684..10481e8e 100644
--- a/commands/account/search.go
+++ b/commands/account/search.go
@@ -42,15 +42,15 @@ func (SearchFilter) Aliases() []string {
}
func (*SearchFilter) CompleteFlag(arg string) []string {
- return commands.CompletionFromList(commands.GetFlagList(), arg)
+ return commands.FilterList(commands.GetFlagList(), arg, commands.QuoteSpace)
}
func (*SearchFilter) CompleteAddress(arg string) []string {
- return commands.CompletionFromList(commands.GetAddress(arg), arg)
+ return commands.FilterList(commands.GetAddress(arg), arg, commands.QuoteSpace)
}
func (*SearchFilter) CompleteDate(arg string) []string {
- return commands.CompletionFromList(commands.GetDateList(), arg)
+ return commands.FilterList(commands.GetDateList(), arg, commands.QuoteSpace)
}
func (s *SearchFilter) ParseRead(arg string) error {
diff --git a/commands/account/sort.go b/commands/account/sort.go
index ccccab25..3103a388 100644
--- a/commands/account/sort.go
+++ b/commands/account/sort.go
@@ -38,7 +38,7 @@ var supportedCriteria = []string{
}
func (*Sort) CompleteCriteria(arg string) []string {
- return commands.CompletionFromList(supportedCriteria, arg)
+ return commands.FilterList(supportedCriteria, arg, commands.QuoteSpace)
}
func (Sort) Execute(args []string) error {