Preserve comments between formatting

This commit is contained in:
世界
2026-04-28 08:10:05 +08:00
parent a37fcd59bb
commit 7d13cabb6a
2 changed files with 15 additions and 0 deletions
+2
View File
@@ -38,10 +38,12 @@ func format() error {
return err
}
for _, optionsEntry := range optionsList {
comments := optionsEntry.options.Comments()
optionsEntry.options, err = badjson.Omitempty(globalCtx, optionsEntry.options)
if err != nil {
return err
}
optionsEntry.options.SetComments(comments)
buffer := new(bytes.Buffer)
encoder := json.NewEncoder(buffer)
encoder.SetIndent("", " ")