Fix caret position when a line has multiple runs (e.g. there's an emoji present)

This commit is contained in:
David Capello 2025-10-06 15:32:45 -03:00
parent 27cd52ba3b
commit b93a2fc035
1 changed files with 3 additions and 5 deletions

View File

@ -829,16 +829,14 @@ void TextEdit::Line::insertText(int pos, const std::string& str)
text.insert(utfSize[pos - 1].end, str);
}
gfx::Rect TextEdit::Line::getBounds(int glyph) const
gfx::Rect TextEdit::Line::getBounds(const int glyph) const
{
int advance = 0;
gfx::Rect result;
blob->visitRuns([&](const text::TextBlob::RunInfo& run) {
blob->visitRuns([&advance, &result, glyph](const text::TextBlob::RunInfo& run) {
for (int i = 0; i < run.glyphCount; ++i) {
if (advance == glyph) {
if (advance == glyph)
result = run.getGlyphBounds(i);
return;
}
++advance;
}
});