From f92ff9457879ab953fb09a8a68ee7d42276d007b Mon Sep 17 00:00:00 2001 From: k1LoW Date: Mon, 9 Mar 2020 22:53:26 +0900 Subject: [PATCH] Combine conditions --- ast/ast.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ast/ast.go b/ast/ast.go index 839b6c53..a16c5efa 100644 --- a/ast/ast.go +++ b/ast/ast.go @@ -730,13 +730,9 @@ func (n *MappingValueNode) String() string { return fmt.Sprintf("%s%s: %s", space, n.Key.String(), n.Value.String()) } else if keyIndentLevel < valueIndentLevel { return fmt.Sprintf("%s%s:\n%s", space, n.Key.String(), n.Value.String()) - } else if m, ok := n.Value.(*MappingNode); ok && m.IsFlowStyle { + } else if m, ok := n.Value.(*MappingNode); ok && (m.IsFlowStyle || len(m.Values) == 0) { return fmt.Sprintf("%s%s: %s", space, n.Key.String(), n.Value.String()) - } else if m, ok := n.Value.(*MappingNode); ok && len(m.Values) == 0 { - return fmt.Sprintf("%s%s: %s", space, n.Key.String(), n.Value.String()) - } else if s, ok := n.Value.(*SequenceNode); ok && s.IsFlowStyle { - return fmt.Sprintf("%s%s: %s", space, n.Key.String(), n.Value.String()) - } else if s, ok := n.Value.(*SequenceNode); ok && len(s.Values) == 0 { + } else if s, ok := n.Value.(*SequenceNode); ok && (s.IsFlowStyle || len(s.Values) == 0) { return fmt.Sprintf("%s%s: %s", space, n.Key.String(), n.Value.String()) } else if _, ok := n.Value.(*AnchorNode); ok { return fmt.Sprintf("%s%s: %s", space, n.Key.String(), n.Value.String())