fixing property comment handling

This commit is contained in:
Mike Farah 2022-10-25 16:00:19 +11:00
parent 23b2aa5668
commit fe27ddedc0
2 changed files with 5 additions and 3 deletions

View File

@ -51,8 +51,8 @@ func (dec *propertiesDecoder) applyProperty(properties *properties.Properties, c
value, _ := properties.Get(key)
path := parsePropKey(key)
log.Debug("comments: %v", properties.GetComments(key))
log.Debug("comment: %v", properties.GetComment(key))
IMPROVEMENT - target the key node with the comment, set as a header comment instead.
rhsNode := &yaml.Node{
Value: value,
Tag: "!!str",

View File

@ -75,7 +75,9 @@ func (pe *propertiesEncoder) Encode(writer io.Writer, node *yaml.Node) error {
}
func (pe *propertiesEncoder) doEncode(p *properties.Properties, node *yaml.Node, path string) error {
p.SetComment(path, strings.ReplaceAll(headAndLineComment(node), "\n", "\n# "))
commentsWithSpaces := strings.ReplaceAll(headAndLineComment(node), "\n", "\n ")
p.SetComments(path, strings.Split(commentsWithSpaces, "\n"))
switch node.Kind {
case yaml.ScalarNode:
var nodeValue string