diff options
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | commands/account/mkdir.go | 20 |
2 files changed, 20 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index a4b73809..435ddd62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Warn before sending emails with an empty subject with `empty-subject-warning` in `aerc.conf`. - IMAP now uses the delimiter advertised by the server +- Completions for `:mkdir` ### Fixed diff --git a/commands/account/mkdir.go b/commands/account/mkdir.go index 8a260c05..02d997e4 100644 --- a/commands/account/mkdir.go +++ b/commands/account/mkdir.go @@ -20,7 +20,25 @@ func (MakeDir) Aliases() []string { } func (MakeDir) Complete(aerc *widgets.Aerc, args []string) []string { - return nil + if len(args) == 0 { + return nil + } + name := strings.Join(args, " ") + + list := aerc.SelectedAccount().Directories().List() + inboxes := make([]string, len(list)) + copy(inboxes, list) + + // remove inboxes that don't match and append the path separator to all + // others + for i := len(inboxes) - 1; i >= 0; i-- { + if !strings.HasPrefix(inboxes[i], name) && name != "" { + inboxes = append(inboxes[:i], inboxes[i+1:]...) + continue + } + inboxes[i] += aerc.SelectedAccount().Worker().PathSeparator() + } + return inboxes } func (MakeDir) Execute(aerc *widgets.Aerc, args []string) error { |