Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider the GlyphWidth when calculate the postion of matched word in URL detecting #8124

Merged
3 commits merged into from
Nov 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/buffer/out/textBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "../types/inc/utils.hpp"
#include "../types/inc/convert.hpp"
#include "../../types/inc/GlyphWidth.hpp"

#pragma hdrstop

Expand Down Expand Up @@ -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<SHORT>(start % rowSize), gsl::narrow<SHORT>(start / rowSize) };
Expand Down