diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 63507ae16371a48afacb96bf0c52d7d976482595..414e5c7bb267e24a24262a7baafdd27f50c59b86 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -1245,7 +1245,7 @@ bool BaseTextEditor::isParenthesesMatchingEnabled() const void BaseTextEditor::setHighlightCurrentLine(bool b) { d->m_highlightCurrentLine = b; - slotCursorPositionChanged(); + updateCurrentLineHighlight(); } bool BaseTextEditor::highlightCurrentLine() const @@ -2582,6 +2582,22 @@ void BaseTextEditor::saveCurrentCursorPositionForNavigation() d->m_tempNavigationState = saveState(); } +void BaseTextEditor::updateCurrentLineHighlight() +{ + QList<QTextEdit::ExtraSelection> extraSelections; + + if (d->m_highlightCurrentLine) { + QTextEdit::ExtraSelection sel; + sel.format.setBackground(d->m_currentLineFormat.background()); + sel.format.setProperty(QTextFormat::FullWidthSelection, true); + sel.cursor = textCursor(); + sel.cursor.clearSelection(); + extraSelections.append(sel); + } + + setExtraSelections(CurrentLineSelection, extraSelections); +} + void BaseTextEditor::slotCursorPositionChanged() { if (!d->m_contentsChanged && d->m_lastCursorChangeWasInteresting) { @@ -2602,18 +2618,7 @@ void BaseTextEditor::slotCursorPositionChanged() } } - QList<QTextEdit::ExtraSelection> extraSelections; - - if (d->m_highlightCurrentLine) { - QTextEdit::ExtraSelection sel; - sel.format.setBackground(d->m_currentLineFormat.background()); - sel.format.setProperty(QTextFormat::FullWidthSelection, true); - sel.cursor = textCursor(); - sel.cursor.clearSelection(); - extraSelections.append(sel); - } - - setExtraSelections(CurrentLineSelection, extraSelections); + updateCurrentLineHighlight(); if (d->m_displaySettings.m_highlightBlocks) { QTextCursor cursor = textCursor(); @@ -3898,7 +3903,8 @@ void BaseTextEditor::setFontSettings(const TextEditor::FontSettings &fs) d->m_matchFormat.setForeground(parenthesesFormat.foreground()); d->m_rangeFormat.setBackground(parenthesesFormat.background()); - slotUpdateExtraAreaWidth(); + slotUpdateExtraAreaWidth(); // Adjust to new font width + updateCurrentLineHighlight(); // Make sure it takes the new color } void BaseTextEditor::setTabSettings(const TabSettings &ts) diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h index 9dd9240579196eb7d61ffd56bfa93ad5bbaf6e0e..5bcf962ed9e1c411287576348f951130c82548a9 100644 --- a/src/plugins/texteditor/basetexteditor.h +++ b/src/plugins/texteditor/basetexteditor.h @@ -526,6 +526,7 @@ private: void moveLineUpDown(bool up); void copyLineUpDown(bool up); void saveCurrentCursorPositionForNavigation(); + void updateCurrentLineHighlight(); void drawFoldingMarker(QPainter *painter, const QPalette &pal, const QRect &rect,