Commit c67d701a authored by Alejandro-FA's avatar Alejandro-FA Committed by Jesse Beder
Browse files

Fix indentation of empty sequences and add test

parent 9eb11429
...@@ -213,7 +213,8 @@ void Emitter::EmitEndSeq() { ...@@ -213,7 +213,8 @@ void Emitter::EmitEndSeq() {
if (m_pState->CurGroupFlowType() == FlowType::Flow) { if (m_pState->CurGroupFlowType() == FlowType::Flow) {
if (m_stream.comment()) if (m_stream.comment())
m_stream << "\n"; m_stream << "\n";
m_stream << IndentTo(m_pState->CurIndent()); if (originalType == FlowType::Block || m_pState->HasBegunNode())
m_stream << IndentTo(m_pState->CurIndent());
if (originalType == FlowType::Block) { if (originalType == FlowType::Block) {
m_stream << "["; m_stream << "[";
} else { } else {
......
...@@ -176,6 +176,17 @@ TEST_F(EmitterTest, EmptyFlowSeqWithBegunContent) { ...@@ -176,6 +176,17 @@ TEST_F(EmitterTest, EmptyFlowSeqWithBegunContent) {
]])"); ]])");
} }
TEST_F(EmitterTest, EmptyFlowSeqInMap) {
out << BeginMap;
out << Key << Flow << BeginSeq << EndSeq;
out << Value << 1;
out << Key << 2;
out << Value << Flow << BeginSeq << EndSeq;
out << EndMap;
ExpectEmit("[]: 1\n2: []");
}
TEST_F(EmitterTest, EmptyFlowMapWithBegunContent) { TEST_F(EmitterTest, EmptyFlowMapWithBegunContent) {
out << Flow; out << Flow;
out << BeginSeq; out << BeginSeq;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment