diff options
author | Kalyan Sriram <kalyan@coderkalyan.com> | 2021-11-13 08:10:09 +0000 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2021-11-13 15:25:04 +0100 |
commit | 402612fd9788f071a5d7ae0045989977b98d896f (patch) | |
tree | 7d48f203a922cb6933146bda744f5dc3a9e90b07 /widgets | |
parent | 88d28908d2b2cd9d416bce76f384153ba1267cdb (diff) | |
download | aerc-402612fd9788f071a5d7ae0045989977b98d896f.tar.gz |
notmuch: allow sort by file order
When using the notmuch backend, it often makes more sense to sort
folders (actual virtual folders, or queries) by the order specified in
the query-map file, rather than alphabetically. This patch introduces a
configuration option (disabled by default) that allows this.
Additionally, due to the notmuch backend previously using maps (which
are order-undefined) to store the list of queries, default query
selection on aerc startup fluctuated. This patch fixes that by using
slices to store query order.
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/dirlist.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/widgets/dirlist.go b/widgets/dirlist.go index 4db80a43..0345380c 100644 --- a/widgets/dirlist.go +++ b/widgets/dirlist.go @@ -105,7 +105,9 @@ func (dirlist *DirectoryList) Select(name string) { if !hasSelected && dirlist.selected != "" { dirlist.dirs = append(dirlist.dirs, dirlist.selected) } - sort.Strings(dirlist.dirs) + if dirlist.acctConf.EnableFoldersSort { + sort.Strings(dirlist.dirs) + } dirlist.sortDirsByFoldersSortConfig() } dirlist.Invalidate() @@ -376,6 +378,10 @@ func folderMatches(folder string, pattern string) bool { // AccountConfig.FoldersSort option. Folders not included in the option // will be appended at the end in alphabetical order func (dirlist *DirectoryList) sortDirsByFoldersSortConfig() { + if !dirlist.acctConf.EnableFoldersSort { + return + } + sort.Slice(dirlist.dirs, func(i, j int) bool { foldersSort := dirlist.acctConf.FoldersSort iInFoldersSort := findString(foldersSort, dirlist.dirs[i]) |