diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go index 7f5757447..aa891d1f1 100644 --- a/pkg/config/app_config.go +++ b/pkg/config/app_config.go @@ -9,6 +9,7 @@ import ( "github.com/adrg/xdg" "github.com/jesseduffield/lazygit/pkg/utils/yaml_utils" yaml "github.com/jesseduffield/yaml" + yaml3 "gopkg.in/yaml.v3" ) // AppConfig contains the base configuration fields required for lazygit. @@ -180,6 +181,11 @@ func migrateUserConfig(path string, content []byte) ([]byte, error) { return nil, fmt.Errorf("Couldn't migrate config file at `%s`: %s", path, err) } + changedContent, err = changeNullKeybindingsToDisabled(changedContent) + if err != nil { + return nil, fmt.Errorf("Couldn't migrate config file at `%s`: %s", path, err) + } + // Add more migrations here... // Write config back if changed @@ -193,6 +199,17 @@ func migrateUserConfig(path string, content []byte) ([]byte, error) { return content, nil } +func changeNullKeybindingsToDisabled(changedContent []byte) ([]byte, error) { + return yaml_utils.Walk(changedContent, func(node *yaml3.Node, path string) bool { + if strings.HasPrefix(path, "keybinding.") && node.Kind == yaml3.ScalarNode && node.Tag == "!!null" { + node.Value = "" + node.Tag = "!!str" + return true + } + return false + }) +} + func (c *AppConfig) GetDebug() bool { return c.Debug }