From c750afe0e0f043389d30850070889946e4c6e8af Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Mon, 19 Sep 2011 13:20:13 +0200 Subject: Make sure cursor position doesn't exceed line end If we have trailing spaces at the end of a line, cursor will disappear because the position we returned exceeds line end, thus the widget border. By limiting it within line.width we can make sure it always visible, which is more consistent to the behavior in common platforms. Reviewed-by: Eskil --- src/gui/text/qtextlayout.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index d0c1a0e..a2662c4 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -2612,6 +2612,9 @@ qreal QTextLine::cursorToX(int *cursorPos, Edge edge) const x += eng->offsetInLigature(si, pos, end, glyph_pos); } + if (x > line.width) + x = line.width; + *cursorPos = pos + si->position; return x.toReal(); } -- cgit v0.12