diff options
author | Keenan Gugeler <me@kgugeler.ca> | 2023-08-18 19:04:59 +0000 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-08-25 14:07:22 +0200 |
commit | 71692aeb2426543455044d8c3b7565caf173906e (patch) | |
tree | cde218c5245219dc12372b20be76a8048713bd4f /widgets/compose.go | |
parent | 7304781d889ad75c91d37cc6feeaeb7b9fc05a9e (diff) | |
download | aerc-71692aeb2426543455044d8c3b7565caf173906e.tar.gz |
review: sort unknown review commands
Currently, the unknown commands in the review window appear in an undefined
order, since `go-ini` gives us a `map`. Instead, we should sort them by
inputs, otherwise the ordering can get confusing between restarts of
aerc.
Signed-off-by: Keenan Gugeler <me@kgugeler.ca>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'widgets/compose.go')
-rw-r--r-- | widgets/compose.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/widgets/compose.go b/widgets/compose.go index 0aac8705..89697097 100644 --- a/widgets/compose.go +++ b/widgets/compose.go @@ -8,6 +8,7 @@ import ( "net/textproto" "os" "os/exec" + "sort" "strconv" "strings" "sync" @@ -1604,6 +1605,7 @@ func newReviewMessage(composer *Composer, err error) *reviewMessage { {":abort<enter>", "Abort (discard message, no confirmation)", ""}, {":choose -o d discard abort -o p postpone postpone<enter>", "Abort or postpone", ""}, } + knownCommands := len(reviewCommands) var actions []string for _, binding := range bindings.Bindings { inputs := config.FormatKeyStrokes(binding.Input) @@ -1626,6 +1628,11 @@ func newReviewMessage(composer *Composer, err error) *reviewMessage { reviewCommands = append(reviewCommands, rcmd) } } + unknownCommands := reviewCommands[knownCommands:] + sort.Slice(unknownCommands, func(i, j int) bool { + return unknownCommands[i][2] < unknownCommands[j][2] + }) + longest := 0 for _, rcmd := range reviewCommands { if len(rcmd[2]) > longest { |