Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add IsFlowStyle field to MappingValueNode
Browse files Browse the repository at this point in the history
semihbkgr committed Jan 18, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent f739772 commit 021dbbe
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ast/ast.go
Original file line number Diff line number Diff line change
@@ -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",

0 comments on commit 021dbbe

Please sign in to comment.