Added a parameter to fix the offset column of comments for pretty formatting

This commit is contained in:
Ryan Krattiger 2017-07-28 15:08:31 -04:00
parent 11607eb5bf
commit f8ff3ac8e4
2 changed files with 10 additions and 3 deletions

View File

@ -113,11 +113,13 @@ inline _Tag SecondaryTag(const std::string content) {
}
struct _Comment {
_Comment(const std::string& content_) : content(content_) {}
_Comment(const std::string& content_, int col = -1) : content(content_), indent_col(col), indent_to(col > 0) {}
std::string content;
size_t indent_col;
bool indent_to;
};
inline _Comment Comment(const std::string content) { return _Comment(content); }
inline _Comment Comment(const std::string content, int col = -1) { return _Comment(content, col); }
struct _Precision {
_Precision(int floatPrecision_, int doublePrecision_)

View File

@ -874,7 +874,12 @@ Emitter& Emitter::Write(const _Comment& comment) {
PrepareNode(EmitterNodeType::NoType);
if (m_stream.col() > 0)
m_stream << Indentation(m_pState->GetPreCommentIndent());
{
if(comment.indent_to && comment.indent_col > m_stream.col())
m_stream << IndentTo(comment.indent_col);
else
m_stream << Indentation(m_pState->GetPreCommentIndent());
}
Utils::WriteComment(m_stream, comment.content,
m_pState->GetPostCommentIndent());