From 314ba1d0ae32d5af55bd176dadff96e277645a33 Mon Sep 17 00:00:00 2001 From: Tyagiquamar Date: Thu, 1 Oct 2026 17:23:38 +0530 Subject: [PATCH] fix(emitter): preserve trailing newline in keep block chomping (+) Signed-off-by: Tyagiquamar --- src/emitterutils.cpp | 1 - test/integration/emitter_test.cpp | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/emitterutils.cpp b/src/emitterutils.cpp index 57f41ac38..d248ab6bb 100644 --- a/src/emitterutils.cpp +++ b/src/emitterutils.cpp @@ -416,7 +416,6 @@ bool WriteLiteralString(ostream_wrapper& out, const char* str, std::size_t size, size -= 1; } else { // 'keep' out << "|+\n"; - size -= 1; } int codePoint; for (const char* i = str; diff --git a/test/integration/emitter_test.cpp b/test/integration/emitter_test.cpp index 8dc3d6d26..8085a7012 100644 --- a/test/integration/emitter_test.cpp +++ b/test/integration/emitter_test.cpp @@ -454,6 +454,7 @@ TEST_F(EmitterTest, LiteralWithAndWithoutTrailingEmptyLines) { out << BeginSeq; out << Literal << "A\nB"; out << Literal << "A\nB\n"; + out << Literal << "A\nB\n\n"; out << Literal << "A\nB\n\n\n"; out << "something"; out << EndSeq; @@ -462,6 +463,7 @@ TEST_F(EmitterTest, LiteralWithAndWithoutTrailingEmptyLines) { "- |-\n A\n B\n" "- |\n A\n B\n" "- |+\n A\n B\n\n\n" + "- |+\n A\n B\n\n\n\n" "- something"); }