diff --git a/src/buffer/out/textBuffer.cpp b/src/buffer/out/textBuffer.cpp index 2c24936c2bd..24ef10da53c 100644 --- a/src/buffer/out/textBuffer.cpp +++ b/src/buffer/out/textBuffer.cpp @@ -8,6 +8,7 @@ #include "../types/inc/utils.hpp" #include "../types/inc/convert.hpp" +#include "../../types/inc/GlyphWidth.hpp" #pragma hdrstop @@ -2428,9 +2429,19 @@ PointTree TextBuffer::GetPatterns(const size_t firstRow, const size_t lastRow) c // when we find a match, the prefix is text that is between this // match and the previous match, so we use the size of the prefix // along with the size of the match to determine the locations - const auto prefixSize = i->prefix().str().size(); + size_t prefixSize = 0; + + for (const auto ch : i->prefix().str()) + { + prefixSize += IsGlyphFullWidth(ch) ? 2 : 1; + } const auto start = lenUpToThis + prefixSize; - const auto end = start + i->str().size(); + size_t matchSize = 0; + for (const auto ch : i->str()) + { + matchSize += IsGlyphFullWidth(ch) ? 2 : 1; + } + const auto end = start + matchSize; lenUpToThis = end; const til::point startCoord{ gsl::narrow(start % rowSize), gsl::narrow(start / rowSize) };