sort key bindings before listing

Mentioned in #1.
This commit is contained in:
Gokcehan 2016-08-24 13:08:49 +03:00
parent fb26551693
commit b90bd273f7

11
ui.go
View File

@ -7,6 +7,7 @@ import (
"log" "log"
"os" "os"
"path" "path"
"sort"
"strings" "strings"
"text/tabwriter" "text/tabwriter"
"time" "time"
@ -520,10 +521,16 @@ func (ui *UI) listBinds(binds map[string]Expr) {
t := new(tabwriter.Writer) t := new(tabwriter.Writer)
b := new(bytes.Buffer) b := new(bytes.Buffer)
var keys []string
for k := range binds {
keys = append(keys, k)
}
sort.Strings(keys)
t.Init(b, 0, gOpts.tabstop, 2, '\t', 0) t.Init(b, 0, gOpts.tabstop, 2, '\t', 0)
fmt.Fprintln(t, "keys\tcommand") fmt.Fprintln(t, "keys\tcommand")
for key, expr := range binds { for _, k := range keys {
fmt.Fprintf(t, "%s\t%v\n", key, expr) fmt.Fprintf(t, "%s\t%v\n", k, binds[k])
} }
t.Flush() t.Flush()