Don't position cursor inside complex graphemes when clicking outside line
If you clicked to the right of a text line ended with a grapheme consisting of several characters, either because it was a unicode surrogate pair or a ligature, we would always to the previous character in logical order, without checking if this was a valid cursor position. One result of this would be that hitting backspace when the cursor was positioned in an invalid position, would cause the entire contents of the document to become invalid. Instead we should search backwards for the previous grapheme boundary using QTextEngine::previousLogicalPosition(). [ChangeLog][QtGui][Text] Fixed position of text cursor set by clicking outside the bounds of a text line that ends with a surrogate pair or ligature. Task-number: QTBUG-69085 Change-Id: I7224c065f332f398bdfbb3f42b2b3ec8280c76a4 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
parent
451fcee8a8
commit
bc71946487
@ -3002,9 +3002,8 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const
|
||||
// character between lines is a space and we want
|
||||
// to position the cursor to the left of that
|
||||
// character.
|
||||
// ###### breaks with japanese for example
|
||||
if (this->index < eng->lines.count() - 1)
|
||||
--maxPos;
|
||||
maxPos = eng->previousLogicalPosition(maxPos);
|
||||
|
||||
pos = qMin(pos, maxPos);
|
||||
return pos;
|
||||
|
Loading…
x
Reference in New Issue
Block a user