From e2a9cd0881593c3b3a24863ceb535367c5570888 Mon Sep 17 00:00:00 2001 From: Bence Ferdinandy Date: Fri, 21 Jun 2024 21:55:33 +0200 Subject: query: allow forcing overwrite of existing folder Currently, when using :query the user is forced to create a new folder for every query, since aerc doesn't allow overwriting an existing folder. Actually, "overwriting" an existing folder with a query is a non-destructive operation in the sense, that the underlying maildir is not touched, the only thing lost is the state in aerc. The current behaviour doesn't allow for a simple `:query -n query ` type of binding. Allow overwriting an existing folder with the -f flag. Changelog-added: Allow using existing directory name with `:query -f`. Signed-off-by: Bence Ferdinandy Acked-by: Robin Jarry --- app/dirlist.go | 7 ++++--- app/dirtree.go | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'app') diff --git a/app/dirlist.go b/app/dirlist.go index 1fc2dd63..7dff934c 100644 --- a/app/dirlist.go +++ b/app/dirlist.go @@ -24,7 +24,7 @@ type DirectoryLister interface { Selected() string Select(string) - Open(string, string, time.Duration, func(types.WorkerMessage)) + Open(string, string, time.Duration, func(types.WorkerMessage), bool) Update(types.WorkerMessage) List() []string @@ -175,11 +175,11 @@ func (dirlist *DirectoryList) ExpandFolder() { } func (dirlist *DirectoryList) Select(name string) { - dirlist.Open(name, "", dirlist.UiConfig(name).DirListDelay, nil) + dirlist.Open(name, "", dirlist.UiConfig(name).DirListDelay, nil, false) } func (dirlist *DirectoryList) Open(name string, query string, delay time.Duration, - cb func(types.WorkerMessage), + cb func(types.WorkerMessage), force bool, ) { dirlist.selecting = name @@ -194,6 +194,7 @@ func (dirlist *DirectoryList) Open(name string, query string, delay time.Duratio Context: ctx, Directory: name, Query: query, + Force: force, }, func(msg types.WorkerMessage) { switch msg := msg.(type) { diff --git a/app/dirtree.go b/app/dirtree.go index b735dacd..a7d0a5e7 100644 --- a/app/dirtree.go +++ b/app/dirtree.go @@ -239,10 +239,10 @@ func (dt *DirectoryTree) Select(name string) { if name == "" { return } - dt.Open(name, "", dt.UiConfig(name).DirListDelay, nil) + dt.Open(name, "", dt.UiConfig(name).DirListDelay, nil, false) } -func (dt *DirectoryTree) Open(name string, query string, delay time.Duration, cb func(types.WorkerMessage)) { +func (dt *DirectoryTree) Open(name string, query string, delay time.Duration, cb func(types.WorkerMessage), force bool) { if name == "" { return } @@ -263,7 +263,7 @@ func (dt *DirectoryTree) Open(name string, query string, delay time.Duration, cb dt.buildTree() dt.reindex(name) } - }) + }, force) } func (dt *DirectoryTree) NextPrev(delta int) { -- cgit