Fixed self assigned issue #1107

This commit is contained in:
Mike Farah
2022-02-20 14:29:52 +11:00
parent fc447b46ce
commit 665f6b0267
5 changed files with 53 additions and 6 deletions
+28
View File
@@ -245,7 +245,35 @@ func recursiveNodeEqual(lhs *yaml.Node, rhs *yaml.Node) bool {
return recurseNodeObjectEqual(lhs, rhs)
}
return false
}
func deepCloneContent(content []*yaml.Node) []*yaml.Node {
clonedContent := make([]*yaml.Node, len(content))
for i, child := range content {
clonedContent[i] = deepClone(child)
}
return clonedContent
}
func deepClone(node *yaml.Node) *yaml.Node {
if node == nil {
return nil
}
clonedContent := deepCloneContent(node.Content)
return &yaml.Node{
Content: clonedContent,
Kind: node.Kind,
Style: node.Style,
Tag: node.Tag,
Value: node.Value,
Anchor: node.Anchor,
Alias: deepClone(node.Alias),
HeadComment: node.HeadComment,
LineComment: node.LineComment,
FootComment: node.FootComment,
Line: node.Line,
Column: node.Column,
}
}
// yaml numbers can be hex encoded...