"git@developer.sourcefind.cn:gaoqiong/yaml-cpp.git" did not exist on "8aabc0766b694188551626389a0afdd90de9b1da"
Commit 23fb2dc8 authored by Jesse Beder's avatar Jesse Beder
Browse files

Fixed basic block seq indentation

parent b5d8241d
...@@ -313,12 +313,14 @@ namespace YAML ...@@ -313,12 +313,14 @@ namespace YAML
void Emitter::BlockSeqPrepareNode() void Emitter::BlockSeqPrepareNode()
{ {
const unsigned curIndent = m_pState->CurIndent(); const unsigned curIndent = m_pState->CurIndent();
if(m_stream.col() > curIndent) { if(!m_pState->HasTag() && !m_pState->HasAnchor()) {
m_stream << "\n"; if(m_pState->CurGroupChildCount() > 0) {
m_stream << "\n";
}
m_stream << IndentTo(curIndent);
m_stream << "-";
m_stream << IndentTo(curIndent + m_pState->CurGroupIndent());
} }
m_stream << IndentTo(curIndent);
m_stream << "-";
m_stream << IndentTo(curIndent + m_pState->CurGroupIndent());
} }
void Emitter::FlowMapPrepareNode() void Emitter::FlowMapPrepareNode()
......
...@@ -119,6 +119,11 @@ namespace YAML ...@@ -119,6 +119,11 @@ namespace YAML
return m_groups.empty() ? 0 : m_groups.top().indent; return m_groups.empty() ? 0 : m_groups.top().indent;
} }
std::size_t EmitterState::CurGroupChildCount() const
{
return m_groups.empty() ? 0 : m_groups.top().childCount;
}
void EmitterState::ClearModifiedSettings() void EmitterState::ClearModifiedSettings()
{ {
m_modifiedSettings.clear(); m_modifiedSettings.clear();
......
...@@ -40,6 +40,7 @@ namespace YAML ...@@ -40,6 +40,7 @@ namespace YAML
GroupType::value CurGroupType() const; GroupType::value CurGroupType() const;
FlowType::value CurGroupFlowType() const; FlowType::value CurGroupFlowType() const;
int CurGroupIndent() const; int CurGroupIndent() const;
std::size_t CurGroupChildCount() const;
int CurIndent() const { return m_curIndent; } int CurIndent() const { return m_curIndent; }
bool HasAnchor() const { return m_hasAnchor; } bool HasAnchor() const { return m_hasAnchor; }
bool HasTag() const { return m_hasTag; } bool HasTag() const { return m_hasTag; }
......
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