aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2023-10-14 01:21:27 +0200
committerRobin Jarry <robin@jarry.cc>2023-10-22 15:12:23 +0200
commit8fdabbc4bfcaf8f0214a66777336a356cc2a0616 (patch)
treedbf8d1e32ab8583f20de6eb3c20015cff8e7b5ff
parent53b455b084d3330384e63574876a70224c77923b (diff)
downloadaerc-8fdabbc4bfcaf8f0214a66777336a356cc2a0616.tar.gz
config: ensure account order as requested
Ensure the account order as requested by the -a option on the command line. The current sorting is not working correctly, since it sorts Accounts []*AccountConfig by comparing the names instead of the indexes of the requested accounts. Fixes: https://todo.sr.ht/~rjarry/aerc/190 Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
-rw-r--r--config/accounts.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/config/accounts.go b/config/accounts.go
index 3a506e6a..dbc0cdb4 100644
--- a/config/accounts.go
+++ b/config/accounts.go
@@ -173,8 +173,12 @@ If you want to disable STARTTLS, append +insecure to the schema.
if len(Accounts) != len(accts) {
return errors.New("account(s) not found")
}
+ idx := make(map[string]int)
+ for i, acct := range accts {
+ idx[acct] = i
+ }
sort.Slice(Accounts, func(i, j int) bool {
- return strings.ToLower(accts[i]) < strings.ToLower(accts[j])
+ return idx[Accounts[i].Name] < idx[Accounts[j].Name]
})
}