aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugins/texteditor/texteditor.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp
index fc9310607c..07f8570483 100644
--- a/src/plugins/texteditor/texteditor.cpp
+++ b/src/plugins/texteditor/texteditor.cpp
@@ -468,7 +468,6 @@ struct PaintEventBlockData
{
QRectF boundingRect;
QVector<QTextLayout::FormatRange> selections;
- QVector<QTextLayout::FormatRange> prioritySelections;
QRectF blockSelectionCursorRect;
QTextLayout *layout = nullptr;
int position = 0;
@@ -4704,6 +4703,7 @@ void TextEditorWidgetPrivate::setupBlockLayout(const PaintEventData &data,
void TextEditorWidgetPrivate::setupSelections(const PaintEventData &data,
PaintEventBlockData &blockData) const
{
+ QVector<QTextLayout::FormatRange> prioritySelections;
for (int i = 0; i < data.context.selections.size(); ++i) {
const QAbstractTextDocumentLayout::Selection &range = data.context.selections.at(i);
const int selStart = range.cursor.selectionStart() - blockData.position;
@@ -4720,18 +4720,25 @@ 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) {
+ const QTextCharFormat selectionFormat = data.fontSettings.toTextCharFormat(C_SELECTION);
+ if (selectionFormat.background().style() != Qt::NoBrush)
+ o.format.setBackground(selectionFormat.background());
+ if (selectionFormat.foreground().style() != Qt::NoBrush)
+ o.format.setForeground(selectionFormat.foreground());
+ }
if ((data.textCursor.hasSelection() && i == data.context.selections.size() - 1)
|| (o.format.foreground().style() == Qt::NoBrush
&& o.format.underlineStyle() != QTextCharFormat::NoUnderline
&& o.format.background() == Qt::NoBrush)) {
if (q->selectionVisible(data.block.blockNumber()))
- blockData.prioritySelections.append(o);
+ prioritySelections.append(o);
} else {
blockData.selections.append(o);
}
}
}
- blockData.selections += blockData.prioritySelections;
+ blockData.selections.append(prioritySelections);
}
void TextEditorWidgetPrivate::setupCursorPosition(PaintEventData &data,