mirror of
https://github.com/mikefarah/yq.git
synced 2024-12-19 20:19:04 +00:00
fixing property comment handling
This commit is contained in:
parent
23b2aa5668
commit
fe27ddedc0
@ -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",
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user