From d0e4252e5ca2c4bca689576b0fa6f30accc01870 Mon Sep 17 00:00:00 2001 From: James Holderness Date: Sat, 28 Nov 2020 19:53:32 +0000 Subject: [PATCH] Make sure trailing DBCS chars are rendered correctly. --- src/renderer/base/renderer.cpp | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/src/renderer/base/renderer.cpp b/src/renderer/base/renderer.cpp index 058ddab9a39..14cf3991058 100644 --- a/src/renderer/base/renderer.cpp +++ b/src/renderer/base/renderer.cpp @@ -764,23 +764,13 @@ void Renderer::_PaintBufferOutputHelper(_In_ IRenderEngine* const pEngine, // (a.k.a. the right half of a two column character), then we need some special handling. if (_clusterBuffer.empty() && it->DbcsAttr().IsTrailing()) { - // If we have room to move to the left to start drawing... - if (screenPoint.X > 0) - { - // Move left to the one so the whole character can be struck correctly. - --screenPoint.X; - // And tell the next function to trim off the left half of it. - trimLeft = true; - // And add one to the number of columns we expect it to take as we insert it. - columnCount = it->Columns() + 1; - _clusterBuffer.emplace_back(it->Chars(), columnCount); - } - else - { - // If we didn't have room, move to the right one and just skip this one. - screenPoint.X++; - continue; - } + // Move left to the one so the whole character can be struck correctly. + --screenPoint.X; + // And tell the next function to trim off the left half of it. + trimLeft = true; + // And add one to the number of columns we expect it to take as we insert it. + columnCount = it->Columns() + 1; + _clusterBuffer.emplace_back(it->Chars(), columnCount); } // Otherwise if it's not a special case, just insert it as is. else @@ -795,7 +785,7 @@ void Renderer::_PaintBufferOutputHelper(_In_ IRenderEngine* const pEngine, } // Advance the cluster and column counts. - it += columnCount > 0 ? columnCount : 1; // prevent infinite loop for no visible columns + it += std::max(it->Columns(), 1); // prevent infinite loop for no visible columns cols += columnCount; } while (it);