commands: implement fuzzy completion for commands and options

Change the option to enable fuzzy completion to be fuzzy-complete, since
it's no longer only used for folders

Signed-off-by: Kt Programs <ktprograms@gmail.com>
Acked-by: Koni Marti <koni.marti@gmail.com>
This commit is contained in:
kt programs 2022-03-06 10:58:07 +08:00 committed by Robin Jarry
parent 55ae3d2cab
commit cc172970a0
12 changed files with 90 additions and 78 deletions
commands

View file

@ -20,17 +20,16 @@ func (ChangeTab) Aliases() []string {
}
func (ChangeTab) Complete(aerc *widgets.Aerc, args []string) []string {
acct := aerc.SelectedAccount()
if acct == nil {
return make([]string, 0)
}
if len(args) == 0 {
return aerc.TabNames()
}
joinedArgs := strings.Join(args, " ")
out := make([]string, 0)
for _, tab := range aerc.TabNames() {
if strings.HasPrefix(tab, joinedArgs) {
out = append(out, tab)
}
}
return out
return FilterList(aerc.TabNames(), joinedArgs, "", acct.UiConfig().FuzzyComplete)
}
func (ChangeTab) Execute(aerc *widgets.Aerc, args []string) error {