From 98c2e106a6c5fd425d77425ee2db31dcd4fab0b7 Mon Sep 17 00:00:00 2001 From: Leonard Hecker Date: Tue, 16 Jul 2024 01:39:29 +0200 Subject: [PATCH 1/2] Fix colors getting lost on reflow --- src/buffer/out/textBuffer.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/buffer/out/textBuffer.cpp b/src/buffer/out/textBuffer.cpp index 553365e4f5e..9075285996a 100644 --- a/src/buffer/out/textBuffer.cpp +++ b/src/buffer/out/textBuffer.cpp @@ -2855,6 +2855,15 @@ void TextBuffer::Reflow(TextBuffer& oldBuffer, TextBuffer& newBuffer, const View } } + // The for loop right after this if condition will copy entire rows of attributes at a time. + // This assumes of course that the "write cursor" (newX, newY) is at the start of a row. + // If we didn't check for this, we may otherwise copy attributes from a later row into a previous one. + if (newX != 0) + { + newX = 0; + newY++; + } + // Finish copying buffer attributes to remaining rows below the last // printable character. This is to fix the `color 2f` scenario, where you // change the buffer colors then resize and everything below the last From b6b8184c0e801497c04e9545138150ee588a1386 Mon Sep 17 00:00:00 2001 From: Leonard Hecker Date: Tue, 30 Jul 2024 17:22:59 +0200 Subject: [PATCH 2/2] Fix unit test --- src/buffer/out/ut_textbuffer/ReflowTests.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/buffer/out/ut_textbuffer/ReflowTests.cpp b/src/buffer/out/ut_textbuffer/ReflowTests.cpp index 191d7329b99..e46e415e37d 100644 --- a/src/buffer/out/ut_textbuffer/ReflowTests.cpp +++ b/src/buffer/out/ut_textbuffer/ReflowTests.cpp @@ -589,13 +589,13 @@ namespace TestBuffer{ { 2, 5 }, // reduce width aggressively { - { L" ", false }, { L" ", true }, { L" ", true }, { L" ", true }, { L" ", true }, + { L" ", false }, }, - { 1, 0 }, + { 1, 4 }, }, }, },