aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2022-03-25 09:31:45 +0100
committerRobin Jarry <robin@jarry.cc>2022-03-31 12:55:07 +0200
commit2fd9cef568e30488f04b6134c81e656cf2a02e95 (patch)
treedb15842871d80eb34e1953593fe789453acb6857
parentfc604b667939bfe52ab8758a9a369e2c63de4dbc (diff)
downloadaerc-2fd9cef568e30488f04b6134c81e656cf2a02e95.tar.gz
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>
-rw-r--r--commands/msgview/save.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/commands/msgview/save.go b/commands/msgview/save.go
index 350739ab..2a5eadf9 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)
}