From 2fd9cef568e30488f04b6134c81e656cf2a02e95 Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Fri, 25 Mar 2022 09:31:45 +0100 Subject: [PATCH] save: fix path completion Ignore option flags and prepend default-save-path if the current path is not absolute. Signed-off-by: Robin Jarry Reviewed-by: Moritz Poldrack --- commands/msgview/save.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/commands/msgview/save.go b/commands/msgview/save.go index 350739a..2a5eadf 100644 --- a/commands/msgview/save.go +++ b/commands/msgview/save.go @@ -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) }