Repository: microsoft/terminal (language: cpp)

Issue:
1.22 Session restoration emits a `[K` even at the end of the line, deleting last character
I believe Dustin gave Leonard the `buffer.json` with the repro


Discussion / hints:

Fix patch:
diff --git a/src/buffer/out/textBuffer.cpp b/src/buffer/out/textBuffer.cpp
index af60c0443dc..03570cf526d 100644
--- a/src/buffer/out/textBuffer.cpp
+++ b/src/buffer/out/textBuffer.cpp
@@ -2790,7 +2790,7 @@ void TextBuffer::Serialize(const wchar_t* destination) const
             // In other words, we can only skip \x1b[K = Erase in Line, if both the first/last attribute are the default attribute.
             static constexpr TextAttribute defaultAttr;
             const auto trimTrailingWhitespaces = it == last && lastCharX < newX;
-            const auto clearToEndOfLine = trimTrailingWhitespaces && beg->value != defaultAttr || beg->value != defaultAttr;
+            const auto clearToEndOfLine = trimTrailingWhitespaces && (beg->value != defaultAttr || last->value != defaultAttr);
 
             if (trimTrailingWhitespaces)
             {


Test patch: