1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-15 00:15:32 +02:00

many more generics

This commit is contained in:
Jesse Duffield
2022-03-19 19:12:58 +11:00
parent bf4f06ab4e
commit 1b75ed3740
31 changed files with 278 additions and 320 deletions

View File

@ -4,6 +4,7 @@ import (
"fmt"
"strings"
"github.com/jesseduffield/generics/slices"
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/config"
"github.com/jesseduffield/lazygit/pkg/gui/context"
@ -77,11 +78,9 @@ func (self *KeybindingCreator) contextForContextKey(contextKey types.ContextKey)
}
func formatUnknownContextError(customCommand config.CustomCommand) error {
// stupid golang making me build an array of strings for this.
allContextKeyStrings := make([]string, len(context.AllContextKeys))
for i := range context.AllContextKeys {
allContextKeyStrings[i] = string(context.AllContextKeys[i])
}
allContextKeyStrings := slices.Map(context.AllContextKeys, func(key types.ContextKey) string {
return string(key)
})
return fmt.Errorf("Error when setting custom command keybindings: unknown context: %s. Key: %s, Command: %s.\nPermitted contexts: %s", customCommand.Context, customCommand.Key, customCommand.Command, strings.Join(allContextKeyStrings, ", "))
}