widget: use byte length when comparing with caret position

Fixes misaligned carets when the Editor text contains code points
represented by multiple UTF-8 bytes. Line lengths should be
measured in bytes instead of glyphs for caret positioning.

Signed-off-by: tainted-bit <sourcehut@taintedbit.com>
This commit is contained in:
tainted-bit
2020-06-12 17:13:57 +02:00
committed by Elias Naur
parent 4c28369aa2
commit 2dc19a3695
+1 -1
View File
@@ -483,7 +483,7 @@ loop:
l := e.lines[carLine]
y += (prevDesc + l.Ascent).Ceil()
prevDesc = l.Descent
if carLine == len(e.lines)-1 || idx+len(l.Layout) > e.rr.caret {
if carLine == len(e.lines)-1 || idx+l.Len > e.rr.caret {
for _, g := range l.Layout {
if idx == e.rr.caret {
break loop