mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-10 20:05:50 +02:00
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.
This commit is contained in:
parent
e90aeb62e5
commit
0cc6e39f0f
2 changed files with 12 additions and 1 deletions
|
@ -56,6 +56,7 @@ func customReflect(v *config.UserConfig) *jsonschema.Schema {
|
|||
if err := r.AddGoComments("github.com/jesseduffield/lazygit/pkg/config", "../config"); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
filterOutDevComments(r)
|
||||
schema := r.Reflect(v)
|
||||
defaultConfig := config.GetDefaultConfig()
|
||||
userConfigSchema := schema.Definitions["UserConfig"]
|
||||
|
@ -76,6 +77,16 @@ func customReflect(v *config.UserConfig) *jsonschema.Schema {
|
|||
return schema
|
||||
}
|
||||
|
||||
func filterOutDevComments(r *jsonschema.Reflector) {
|
||||
for k, v := range r.CommentMap {
|
||||
commentLines := strings.Split(v, "\n")
|
||||
filteredCommentLines := lo.Filter(commentLines, func(line string, _ int) bool {
|
||||
return !strings.Contains(line, "[dev]")
|
||||
})
|
||||
r.CommentMap[k] = strings.Join(filteredCommentLines, "\n")
|
||||
}
|
||||
}
|
||||
|
||||
func setDefaultVals(rootSchema, schema *jsonschema.Schema, defaults any) {
|
||||
t := reflect.TypeOf(defaults)
|
||||
v := reflect.ValueOf(defaults)
|
||||
|
|
|
@ -1468,7 +1468,7 @@
|
|||
},
|
||||
"editInTerminal": {
|
||||
"type": "boolean",
|
||||
"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"
|
||||
"description": "Whether lazygit suspends until an edit process returns"
|
||||
},
|
||||
"openDirInEditor": {
|
||||
"type": "string",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue