From 05ad4e3daa98f6de76c1b5ebc6039da033afea6f Mon Sep 17 00:00:00 2001 From: David Schulz Date: Fri, 16 Oct 2020 14:36:17 +0200 Subject: [PATCH] TextEditor: fix selection highlight Also compare the anchor when looking for the selection. Otherwise we might get a selection highlight that expands on adjacent extra selections like code model warnings. Change-Id: Ib8460c1089ed69d14b7a408ca70e7ac1f8642f6e Reviewed-by: Christian Stenger --- src/plugins/texteditor/texteditor.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 0fdd28182cc..516b82ac724 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -4745,7 +4745,8 @@ void TextEditorWidgetPrivate::setupSelections(const PaintEventData &data, o.start = ts.positionAtColumn(text, m_blockSelection.firstVisualColumn()); o.length = ts.positionAtColumn(text, m_blockSelection.lastVisualColumn()) - o.start; } - if (data.textCursor.hasSelection() && data.textCursor == range.cursor) { + if (data.textCursor.hasSelection() && data.textCursor == range.cursor + && data.textCursor.anchor() == range.cursor.anchor()) { const QTextCharFormat selectionFormat = data.fontSettings.toTextCharFormat(C_SELECTION); if (selectionFormat.background().style() != Qt::NoBrush) o.format.setBackground(selectionFormat.background());