diff --git a/src/buffer/out/textBuffer.cpp b/src/buffer/out/textBuffer.cpp index 58de15c20ea..4ab2366efff 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/Utf16Parser.hpp" #include "../../types/inc/GlyphWidth.hpp" #pragma hdrstop @@ -2535,16 +2536,17 @@ PointTree TextBuffer::GetPatterns(const size_t firstRow, const size_t lastRow) c // match and the previous match, so we use the size of the prefix // along with the size of the match to determine the locations size_t prefixSize = 0; - - for (const auto ch : i->prefix().str()) + for (const std::vector parsedGlyph : Utf16Parser::Parse(i->prefix().str())) { - prefixSize += IsGlyphFullWidth(ch) ? 2 : 1; + const std::wstring_view glyph{ parsedGlyph.data(), parsedGlyph.size() }; + prefixSize += IsGlyphFullWidth(glyph) ? 2 : 1; } const auto start = lenUpToThis + prefixSize; size_t matchSize = 0; - for (const auto ch : i->str()) + for (const std::vector parsedGlyph : Utf16Parser::Parse(i->str())) { - matchSize += IsGlyphFullWidth(ch) ? 2 : 1; + const std::wstring_view glyph{ parsedGlyph.data(), parsedGlyph.size() }; + matchSize += IsGlyphFullWidth(glyph) ? 2 : 1; } const auto end = start + matchSize; lenUpToThis = end;