mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-08-07 22:02:56 +03:00
Add disabled compat for user config (#2833)
Treat <disabled> setting as equivalent to "null" in keybindings user configs.
This commit is contained in:
@@ -691,7 +691,7 @@ func GetDefaultConfig() *UserConfig {
|
||||
NextMatch: "n",
|
||||
PrevMatch: "N",
|
||||
StartSearch: "/",
|
||||
OptionMenu: "",
|
||||
OptionMenu: "<disabled>",
|
||||
OptionMenuAlt1: "?",
|
||||
Select: "<space>",
|
||||
GoInto: "<enter>",
|
||||
|
@@ -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 == "<disabled>" {
|
||||
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)
|
||||
|
26
pkg/integration/tests/misc/disabled_keybindings.go
Normal file
26
pkg/integration/tests/misc/disabled_keybindings.go
Normal file
@@ -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 set keybindings to blank to disable them",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {
|
||||
config.UserConfig.Keybinding.Universal.PrevItem = "<disabled>"
|
||||
config.UserConfig.Keybinding.Universal.NextItem = "<disabled>"
|
||||
config.UserConfig.Keybinding.Universal.NextTab = "<up>"
|
||||
config.UserConfig.Keybinding.Universal.PrevTab = "<down>"
|
||||
},
|
||||
SetupRepo: func(shell *Shell) {},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
Press("<up>")
|
||||
|
||||
t.Views().Worktrees().IsFocused()
|
||||
},
|
||||
})
|
@@ -170,6 +170,7 @@ var tests = []*components.IntegrationTest{
|
||||
interactive_rebase.SwapWithConflict,
|
||||
misc.ConfirmOnQuit,
|
||||
misc.CopyToClipboard,
|
||||
misc.DisabledKeybindings,
|
||||
misc.InitialOpen,
|
||||
misc.RecentReposOnLaunch,
|
||||
patch_building.Apply,
|
||||
|
Reference in New Issue
Block a user