Skip to content

Commit 0fd7b9b

Browse files
authored
Fix json schema for context of CustomCommand (#4255)
- **PR Description** Fix ugly error squiggles in VS Code when using a custom command with a context of e.g. "commits, subCommits". Previously the schema only allowed a single value for the context field; however, it is now possible to specify multiple values separated by comma (see #3784). The only solution that I can see is to get rid of the "enum" specification, and mention the valid values only in the description. Add examples too so that you get at least auto-completion.
2 parents c37376a + 19921b7 commit 0fd7b9b

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Diff for: pkg/config/user_config.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -611,8 +611,8 @@ type CustomCommandAfterHook struct {
611611
type CustomCommand struct {
612612
// The key to trigger the command. Use a single letter or one of the values from https://github.com/jesseduffield/lazygit/blob/master/docs/keybindings/Custom_Keybindings.md
613613
Key string `yaml:"key"`
614-
// The context in which to listen for the key
615-
Context string `yaml:"context" jsonschema:"enum=status,enum=files,enum=worktrees,enum=localBranches,enum=remotes,enum=remoteBranches,enum=tags,enum=commits,enum=reflogCommits,enum=subCommits,enum=commitFiles,enum=stash,enum=global"`
614+
// The context in which to listen for the key. Valid values are: status, files, worktrees, localBranches, remotes, remoteBranches, tags, commits, reflogCommits, subCommits, commitFiles, stash, and global. Multiple contexts separated by comma are allowed; most useful for "commits, subCommits" or "files, commitFiles".
615+
Context string `yaml:"context" jsonschema:"example=status,example=files,example=worktrees,example=localBranches,example=remotes,example=remoteBranches,example=tags,example=commits,example=reflogCommits,example=subCommits,example=commitFiles,example=stash,example=global"`
616616
// The command to run (using Go template syntax for placeholder values)
617617
Command string `yaml:"command" jsonschema:"example=git fetch {{.Form.Remote}} {{.Form.Branch}} && git checkout FETCH_HEAD"`
618618
// If true, run the command in a subprocess (e.g. if the command requires user input)

Diff for: schema/config.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,8 @@
875875
},
876876
"context": {
877877
"type": "string",
878-
"enum": [
878+
"description": "The context in which to listen for the key. Valid values are: status, files, worktrees, localBranches, remotes, remoteBranches, tags, commits, reflogCommits, subCommits, commitFiles, stash, and global. Multiple contexts separated by comma are allowed; most useful for \"commits, subCommits\" or \"files, commitFiles\".",
879+
"examples": [
879880
"status",
880881
"files",
881882
"worktrees",
@@ -889,8 +890,7 @@
889890
"commitFiles",
890891
"stash",
891892
"global"
892-
],
893-
"description": "The context in which to listen for the key"
893+
]
894894
},
895895
"command": {
896896
"type": "string",

0 commit comments

Comments
 (0)