summaryrefslogtreecommitdiff
path: root/commands
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 /commands
parentfc604b667939bfe52ab8758a9a369e2c63de4dbc (diff)
downloadaerc-2fd9cef568e30488f04b6134c81e656cf2a02e95.zip
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>
Diffstat (limited to 'commands')
-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 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)
}