diff --git a/docs/Config.md b/docs/Config.md index 5bdcaed98..b37745b44 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -163,7 +163,7 @@ keybinding: jumpToBlock: ['1', '2', '3', '4', '5'] # goto the Nth block / panel nextMatch: 'n' prevMatch: 'N' - optionMenu: null # show help menu + optionMenu: # show help menu optionMenu-alt1: '?' # show help menu select: '' goInto: '' @@ -462,12 +462,12 @@ Supported versions are "2" and "3". The deprecated config `showIcons` sets the v For all possible keybinding options, check [Custom_Keybindings.md](https://github.com/jesseduffield/lazygit/blob/master/docs/keybindings/Custom_Keybindings.md) -You can disable certain key bindings by specifying `null`. +You can disable certain key bindings by specifying ``. ```yaml keybinding: universal: - edit: null # disable 'edit file' + edit: # disable 'edit file' ``` ### Example Keybindings For Colemak Users diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go index d3d77b666..de0495466 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -691,7 +691,7 @@ func GetDefaultConfig() *UserConfig { NextMatch: "n", PrevMatch: "N", StartSearch: "/", - OptionMenu: "", + OptionMenu: "", OptionMenuAlt1: "?", Select: "", GoInto: "", diff --git a/pkg/gui/keybindings/keybindings.go b/pkg/gui/keybindings/keybindings.go index 4204dc4e1..fd8c694cf 100644 --- a/pkg/gui/keybindings/keybindings.go +++ b/pkg/gui/keybindings/keybindings.go @@ -100,7 +100,9 @@ func LabelFromKey(key types.Key) string { func GetKey(key string) types.Key { runeCount := utf8.RuneCountInString(key) - if runeCount > 1 { + if key == "" { + return nil + } else if runeCount > 1 { binding, ok := keyByLabel[strings.ToLower(key)] if !ok { log.Fatalf("Unrecognized key %s for keybinding. For permitted values see %s", strings.ToLower(key), constants.Links.Docs.CustomKeybindings) diff --git a/pkg/integration/tests/misc/disabled_keybindings.go b/pkg/integration/tests/misc/disabled_keybindings.go new file mode 100644 index 000000000..55e07034d --- /dev/null +++ b/pkg/integration/tests/misc/disabled_keybindings.go @@ -0,0 +1,26 @@ +package misc + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var DisabledKeybindings = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Confirms you can disable keybindings by setting them to ", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) { + config.UserConfig.Keybinding.Universal.PrevItem = "" + config.UserConfig.Keybinding.Universal.NextItem = "" + config.UserConfig.Keybinding.Universal.NextTab = "" + config.UserConfig.Keybinding.Universal.PrevTab = "" + }, + SetupRepo: func(shell *Shell) {}, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Files(). + IsFocused(). + Press("") + + t.Views().Worktrees().IsFocused() + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 89019719a..7759dcda7 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -170,6 +170,7 @@ var tests = []*components.IntegrationTest{ interactive_rebase.SwapWithConflict, misc.ConfirmOnQuit, misc.CopyToClipboard, + misc.DisabledKeybindings, misc.InitialOpen, misc.RecentReposOnLaunch, patch_building.Apply,