File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -243,9 +243,21 @@ class CursorPainter {
243243 final double devicePixelRatio;
244244
245245 /// Paints cursor on [canvas] at specified [position] .
246+ /// [offset] is global top left (x, y) of text line
247+ /// [position] is relative (x) in text line
246248 void paint (Canvas canvas, Offset offset, TextPosition position) {
247- final caretOffset =
248- editable! .getOffsetForCaret (position, prototype) + offset;
249+ // relative (x, y) to global offset
250+ var relativeCaretOffset = editable! .getOffsetForCaret (position, prototype);
251+ if (relativeCaretOffset == Offset .zero) {
252+ relativeCaretOffset = editable! .getOffsetForCaret (
253+ TextPosition (
254+ offset: position.offset - 1 , affinity: position.affinity),
255+ prototype);
256+ // Hardcoded 6 as estimate of the width of a character
257+ relativeCaretOffset =
258+ Offset (relativeCaretOffset.dx + 6 , relativeCaretOffset.dy);
259+ }
260+ final caretOffset = relativeCaretOffset + offset;
249261 var caretRect = prototype.shift (caretOffset);
250262 if (style.offset != null ) {
251263 caretRect = caretRect.shift (style.offset! );
You can’t perform that action at this time.
0 commit comments