Skip to content

Commit 0cc6e39

Browse files
committed
Filter out [dev] comments earlier
Previously we only filtered them out from the example config section in Config.md, but they still appeared in the schema. This is not ideal, because the schema descriptions can appear in editors on mouse hover or in auto-completions. So filter them out earlier, so that they don't appear in the schema either.
1 parent e90aeb6 commit 0cc6e39

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

pkg/jsonschema/generate.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ func customReflect(v *config.UserConfig) *jsonschema.Schema {
5656
if err := r.AddGoComments("github.com/jesseduffield/lazygit/pkg/config", "../config"); err != nil {
5757
panic(err)
5858
}
59+
filterOutDevComments(r)
5960
schema := r.Reflect(v)
6061
defaultConfig := config.GetDefaultConfig()
6162
userConfigSchema := schema.Definitions["UserConfig"]
@@ -76,6 +77,16 @@ func customReflect(v *config.UserConfig) *jsonschema.Schema {
7677
return schema
7778
}
7879

80+
func filterOutDevComments(r *jsonschema.Reflector) {
81+
for k, v := range r.CommentMap {
82+
commentLines := strings.Split(v, "\n")
83+
filteredCommentLines := lo.Filter(commentLines, func(line string, _ int) bool {
84+
return !strings.Contains(line, "[dev]")
85+
})
86+
r.CommentMap[k] = strings.Join(filteredCommentLines, "\n")
87+
}
88+
}
89+
7990
func setDefaultVals(rootSchema, schema *jsonschema.Schema, defaults any) {
8091
t := reflect.TypeOf(defaults)
8192
v := reflect.ValueOf(defaults)

schema/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,7 @@
14681468
},
14691469
"editInTerminal": {
14701470
"type": "boolean",
1471-
"description": "Whether lazygit suspends until an edit process returns\n[dev] Pointer to bool so that we can distinguish unset (nil) from false.\n[dev] We're naming this `editInTerminal` for backwards compatibility"
1471+
"description": "Whether lazygit suspends until an edit process returns"
14721472
},
14731473
"openDirInEditor": {
14741474
"type": "string",

0 commit comments

Comments
 (0)