diff --git a/src/emitterstate.cpp b/src/emitterstate.cpp index d50106c..966c9f4 100644 --- a/src/emitterstate.cpp +++ b/src/emitterstate.cpp @@ -175,8 +175,11 @@ void EmitterState::EndedGroup(GroupType::value type) { // some global settings that we changed may have been overridden // by a local setting we just popped, so we need to restore them m_globalModifiedSettings.restore(); - + ClearModifiedSettings(); + m_hasAnchor = false; + m_hasTag = false; + m_hasNonContent = false; } EmitterNodeType::value EmitterState::CurGroupNodeType() const { diff --git a/test/integration/emitter_test.cpp b/test/integration/emitter_test.cpp index 8e1ee29..464ef76 100644 --- a/test/integration/emitter_test.cpp +++ b/test/integration/emitter_test.cpp @@ -1212,6 +1212,42 @@ TEST_F(EmitterTest, NaN) { "bar: .nan"); } +TEST_F(EmitterTest, ComplexFlowSeqEmbeddingAMapWithNewLine) { + out << YAML::BeginMap; + + out << YAML::Key << "NodeA" << YAML::Value << YAML::BeginMap; + out << YAML::Key << "k" << YAML::Value << YAML::Flow << YAML::BeginSeq; + out << YAML::BeginMap << YAML::Key << "i" << YAML::Value << 0 << YAML::EndMap + << YAML::Newline; + out << YAML::BeginMap << YAML::Key << "i" << YAML::Value << 1 << YAML::EndMap + << YAML::Newline; + out << YAML::EndSeq; + out << YAML::EndMap; + + out << YAML::Key << "NodeB" << YAML::Value << YAML::BeginMap; + out << YAML::Key << "k" << YAML::Value << YAML::Flow << YAML::BeginSeq; + out << YAML::BeginMap << YAML::Key << "i" << YAML::Value << 0 << YAML::EndMap + << YAML::Newline; + out << YAML::BeginMap << YAML::Key << "i" << YAML::Value << 1 << YAML::EndMap + << YAML::Newline; + out << YAML::EndSeq; + out << YAML::EndMap; + + out << YAML::EndMap; + + ExpectEmit( + "NodeA:\n" + " k: [{i: 0},\n" + " {i: 1},\n" + " ]\n" + "NodeB:\n" + " k: [{i: 0},\n" + " {i: 1},\n" + " ]" + ); + +} + class EmitterErrorTest : public ::testing::Test { protected: void ExpectEmitError(const std::string& expectedError) {