more generics

This commit is contained in:
Jesse Duffield 2022-03-19 16:34:46 +11:00
parent eda8f4a5d4
commit bf4f06ab4e
21 changed files with 303 additions and 198 deletions

View file

@ -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