From 32c97a10d04649007dc90245b53d1e1496d5a2bf Mon Sep 17 00:00:00 2001 From: David Schulz Date: Wed, 7 Jun 2023 12:16:37 +0200 Subject: [PATCH] TextEditor: fix painting editor overlay in blocks with preedit text Task-number: QTCREATORBUG-29134 Change-Id: I7049422688fccb421984463e4114546533da55cb Reviewed-by: Marcus Tillmanns --- src/plugins/texteditor/texteditoroverlay.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/plugins/texteditor/texteditoroverlay.cpp b/src/plugins/texteditor/texteditoroverlay.cpp index 5e54f585d2e..4dfed80728b 100644 --- a/src/plugins/texteditor/texteditoroverlay.cpp +++ b/src/plugins/texteditor/texteditoroverlay.cpp @@ -159,6 +159,9 @@ QPainterPath TextEditorOverlay::createSelectionPath(const QTextCursor &begin, co int beginChar = 0; if (block == begin.block()) { beginChar = begin.positionInBlock(); + const QString preeditAreaText = begin.block().layout()->preeditAreaText(); + if (!preeditAreaText.isEmpty() && beginChar >= begin.block().layout()->preeditAreaPosition()) + beginChar += preeditAreaText.length(); QTextLine line = blockLayout->lineForTextPosition(beginChar); QTC_ASSERT(line.isValid(), return {}); firstLine = line.lineNumber(); @@ -171,6 +174,9 @@ QPainterPath TextEditorOverlay::createSelectionPath(const QTextCursor &begin, co int endChar = -1; if (block == end.block()) { endChar = end.positionInBlock(); + const QString preeditAreaText = end.block().layout()->preeditAreaText(); + if (!preeditAreaText.isEmpty() && endChar >= end.block().layout()->preeditAreaPosition()) + endChar += preeditAreaText.length(); QTextLine line = blockLayout->lineForTextPosition(endChar); QTC_ASSERT(line.isValid(), return {}); lastLine = line.lineNumber();