Improved handling of trailing document comments

This commit is contained in:
Mike Farah
2022-05-25 10:54:03 +10:00
parent dee592eb3b
commit 6bce23d9c2
9 changed files with 89 additions and 10 deletions
+5 -1
View File
@@ -14,7 +14,8 @@ type CandidateNode struct {
Parent *CandidateNode // parent node
Key *yaml.Node // node key, if this is a value from a map (or index in an array)
LeadingContent string
LeadingContent string
TrailingContent string
Path []interface{} /// the path we took to get to this node
Document uint // the document index of this node
@@ -170,6 +171,9 @@ func (n *CandidateNode) UpdateAttributesFrom(other *CandidateNode, prefs assignP
if other.Node.FootComment != "" {
n.Node.FootComment = other.Node.FootComment
}
if other.TrailingContent != "" {
n.TrailingContent = other.TrailingContent
}
if other.Node.HeadComment != "" {
n.Node.HeadComment = other.Node.HeadComment
}