From 021dbbe69d07747cfa41100f80d804f6e7c83695 Mon Sep 17 00:00:00 2001 From: semihbkgr Date: Sun, 19 Jan 2025 01:29:27 +0300 Subject: [PATCH] add IsFlowStyle field to MappingValueNode --- ast/ast.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ast/ast.go b/ast/ast.go index 357ca816..55e089bc 100644 --- a/ast/ast.go +++ b/ast/ast.go @@ -1350,6 +1350,7 @@ type MappingValueNode struct { Start *token.Token Key MapKeyNode Value Node + IsFlowStyle bool Anchor *AnchorNode FootComment *CommentGroupNode } @@ -1388,6 +1389,7 @@ func (n *MappingValueNode) AddColumn(col int) { // SetIsFlowStyle set value to IsFlowStyle field recursively. func (n *MappingValueNode) SetIsFlowStyle(isFlow bool) { + n.IsFlowStyle = isFlow switch value := n.Value.(type) { case *MappingNode: value.SetIsFlowStyle(isFlow) @@ -1426,7 +1428,7 @@ func (n *MappingValueNode) toString() string { keyComment := n.Key.GetComment() if _, ok := n.Value.(ScalarNode); ok { return fmt.Sprintf("%s%s: %s", space, n.Key.String(), n.Value.String()) - } else if keyIndentLevel < valueIndentLevel { + } else if keyIndentLevel < valueIndentLevel && !n.IsFlowStyle { if keyComment != nil { return fmt.Sprintf( "%s%s: %s\n%s",