From dc4c34263da7d3f461ca9033ef60cf7859578d61 Mon Sep 17 00:00:00 2001 From: theamarin Date: Sat, 3 Jul 2021 16:55:03 +0200 Subject: [PATCH] Prevent trailing spaces when emitting literal strings This behavior matches the format expectations of the Red Hat yaml language server. --- src/emitterutils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/emitterutils.cpp b/src/emitterutils.cpp index 0113c45..c6ad5e5 100644 --- a/src/emitterutils.cpp +++ b/src/emitterutils.cpp @@ -366,13 +366,13 @@ bool WriteDoubleQuotedString(ostream_wrapper& out, const std::string& str, bool WriteLiteralString(ostream_wrapper& out, const std::string& str, std::size_t indent) { out << "|\n"; - out << IndentTo(indent); int codePoint; for (std::string::const_iterator i = str.begin(); GetNextCodePointAndAdvance(codePoint, i, str.end());) { if (codePoint == '\n') { - out << "\n" << IndentTo(indent); + out << "\n"; } else { + out<< IndentTo(indent); WriteCodePoint(out, codePoint); } }