diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2022-03-19 16:34:46 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-03-24 20:14:41 +1100 |
commit | bf4f06ab4e6ceefe388e0efefcc553526f3d96c2 (patch) | |
tree | b4cfdb71e31fa7d960722f192a56e5fb1a483e5e /pkg/cheatsheet | |
parent | eda8f4a5d4302691d99efd066f9851809c984bc0 (diff) |
more generics
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 |