diff options
Diffstat (limited to 'pkg/cheatsheet')
-rw-r--r-- | pkg/cheatsheet/generate.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/pkg/cheatsheet/generate.go b/pkg/cheatsheet/generate.go index d88f3d733..ecb75f935 100644 --- a/pkg/cheatsheet/generate.go +++ b/pkg/cheatsheet/generate.go @@ -13,6 +13,7 @@ import ( "log" "os" + "github.com/jesseduffield/generics/maps" "github.com/jesseduffield/generics/slices" "github.com/jesseduffield/lazygit/pkg/app" "github.com/jesseduffield/lazygit/pkg/config" @@ -174,11 +175,12 @@ outer: bindings []*types.Binding } - groupedBindings := make([]groupedBindingsType, 0, len(contextAndViewBindingMap)) - - for contextAndView, contextBindings := range contextAndViewBindingMap { - groupedBindings = append(groupedBindings, groupedBindingsType{contextAndView: contextAndView, bindings: contextBindings}) - } + groupedBindings := maps.MapToSlice( + contextAndViewBindingMap, + func(contextAndView contextAndViewType, contextBindings []*types.Binding) groupedBindingsType { + return groupedBindingsType{contextAndView: contextAndView, bindings: contextBindings} + }, + ) slices.SortFunc(groupedBindings, func(a, b groupedBindingsType) bool { first := a.contextAndView |