From 8fdabbc4bfcaf8f0214a66777336a356cc2a0616 Mon Sep 17 00:00:00 2001 From: Koni Marti Date: Sat, 14 Oct 2023 01:21:27 +0200 Subject: 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 Tested-by: Inwit Acked-by: Robin Jarry --- config/accounts.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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] }) } -- cgit