save: fix path completion

Ignore option flags and prepend default-save-path if the current path is
not absolute.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Reviewed-by: Moritz Poldrack <moritz@poldrack.dev>
This commit is contained in:
Robin Jarry 2022-03-25 09:31:45 +01:00
parent fc604b6679
commit 2fd9cef568

View file

@ -30,7 +30,16 @@ func (Save) Aliases() []string {
}
func (Save) Complete(aerc *widgets.Aerc, args []string) []string {
_, optind, _ := getopt.Getopts(args, "fpa")
if optind < len(args) {
args = args[optind:]
}
path := strings.Join(args, " ")
defaultPath := aerc.Config().General.DefaultSavePath
if defaultPath != "" && !isAbsPath(path) {
path = filepath.Join(defaultPath, path)
}
path, _ = homedir.Expand(path)
return commands.CompletePath(path)
}