Skip to content

Commit d02deee

Browse files
committed
Add disabled compat for user config (#2833)
Treat <disabled> setting as equivalent to "null" in keybindings user configs.
1 parent c39fafe commit d02deee

File tree

5 files changed

+34
-5
lines changed

5 files changed

+34
-5
lines changed

docs/Config.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ keybinding:
163163
jumpToBlock: ['1', '2', '3', '4', '5'] # goto the Nth block / panel
164164
nextMatch: 'n'
165165
prevMatch: 'N'
166-
optionMenu: null # show help menu
166+
optionMenu: <disabled> # show help menu
167167
optionMenu-alt1: '?' # show help menu
168168
select: '<space>'
169169
goInto: '<enter>'
@@ -462,12 +462,12 @@ Supported versions are "2" and "3". The deprecated config `showIcons` sets the v
462462

463463
For all possible keybinding options, check [Custom_Keybindings.md](https://github.com/jesseduffield/lazygit/blob/master/docs/keybindings/Custom_Keybindings.md)
464464

465-
You can disable certain key bindings by specifying `null`.
465+
You can disable certain key bindings by specifying `<disabled>`.
466466

467467
```yaml
468468
keybinding:
469469
universal:
470-
edit: null # disable 'edit file'
470+
edit: <disabled> # disable 'edit file'
471471
```
472472

473473
### Example Keybindings For Colemak Users

pkg/config/user_config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ func GetDefaultConfig() *UserConfig {
691691
NextMatch: "n",
692692
PrevMatch: "N",
693693
StartSearch: "/",
694-
OptionMenu: "",
694+
OptionMenu: "<disabled>",
695695
OptionMenuAlt1: "?",
696696
Select: "<space>",
697697
GoInto: "<enter>",

pkg/gui/keybindings/keybindings.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ func LabelFromKey(key types.Key) string {
100100

101101
func GetKey(key string) types.Key {
102102
runeCount := utf8.RuneCountInString(key)
103-
if runeCount > 1 {
103+
if key == "<disabled>" {
104+
return nil
105+
} else if runeCount > 1 {
104106
binding, ok := keyByLabel[strings.ToLower(key)]
105107
if !ok {
106108
log.Fatalf("Unrecognized key %s for keybinding. For permitted values see %s", strings.ToLower(key), constants.Links.Docs.CustomKeybindings)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package misc
2+
3+
import (
4+
"github.com/jesseduffield/lazygit/pkg/config"
5+
. "github.com/jesseduffield/lazygit/pkg/integration/components"
6+
)
7+
8+
var DisabledKeybindings = NewIntegrationTest(NewIntegrationTestArgs{
9+
Description: "Confirms You can set keybindings to blank to disable them",
10+
ExtraCmdArgs: []string{},
11+
Skip: false,
12+
SetupConfig: func(config *config.AppConfig) {
13+
config.UserConfig.Keybinding.Universal.PrevItem = "<disabled>"
14+
config.UserConfig.Keybinding.Universal.NextItem = "<disabled>"
15+
config.UserConfig.Keybinding.Universal.NextTab = "<up>"
16+
config.UserConfig.Keybinding.Universal.PrevTab = "<down>"
17+
},
18+
SetupRepo: func(shell *Shell) {},
19+
Run: func(t *TestDriver, keys config.KeybindingConfig) {
20+
t.Views().Files().
21+
IsFocused().
22+
Press("<up>")
23+
24+
t.Views().Worktrees().IsFocused()
25+
},
26+
})

pkg/integration/tests/test_list.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ var tests = []*components.IntegrationTest{
170170
interactive_rebase.SwapWithConflict,
171171
misc.ConfirmOnQuit,
172172
misc.CopyToClipboard,
173+
misc.DisabledKeybindings,
173174
misc.InitialOpen,
174175
misc.RecentReposOnLaunch,
175176
patch_building.Apply,

0 commit comments

Comments
 (0)