summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2020-02-27 09:35:11 +0100
committerEike Ziller <eike.ziller@qt.io>2020-02-27 09:35:11 +0100
commit56d2dab5feb4062c71fd4480f90bed0cae43bafb (patch)
tree8680560a4c3790d3c22be3394779285b1ddb1683 /src
parent18386c7117e8c0dc7ed40fac2f7b06545f0ebb86 (diff)
parentc912ee6862031b807fc82a76cc5ee95a800eb0bb (diff)
downloadqt-creator-56d2dab5feb4062c71fd4480f90bed0cae43bafb.tar.gz
Merge remote-tracking branch 'origin/4.11' into 4.12
Change-Id: I7e526857a4d9e63838f76d5e3fbb0db7287d5617
Diffstat (limited to 'src')
-rw-r--r--src/plugins/texteditor/texteditor.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp
index e90af4d627..8dd3ff712c 100644
--- a/src/plugins/texteditor/texteditor.cpp
+++ b/src/plugins/texteditor/texteditor.cpp
@@ -646,6 +646,7 @@ public:
MarginSettings m_marginSettings;
// apply when making visible the first time, for the split case
bool m_fontSettingsNeedsApply = true;
+ bool m_wasNotYetShown = true;
BehaviorSettings m_behaviorSettings;
int extraAreaSelectionAnchorBlockNumber = -1;
@@ -4331,16 +4332,12 @@ void TextEditorWidgetPrivate::paintCurrentLineHighlight(const PaintEventData &da
QRectF lineRect = data.block.layout()->lineForTextPosition(data.textCursor.positionInBlock()).rect();
lineRect.moveTop(lineRect.top() + blockRect.top());
lineRect.setLeft(0);
- lineRect.setRight(data.viewportRect.width() - data.offset.x());
+ lineRect.setRight(data.viewportRect.width());
QColor color = m_document->fontSettings().toTextCharFormat(C_CURRENT_LINE).background().color();
// set alpha, otherwise we cannot see block highlighting and find scope underneath
color.setAlpha(128);
- if (!data.eventRect.contains(lineRect.toRect())) {
- QRect updateRect = data.eventRect;
- updateRect.setLeft(0);
- updateRect.setRight(data.viewportRect.width() - int(data.offset.x()));
- q->viewport()->update(updateRect);
- }
+ if (!data.eventRect.contains(lineRect.toRect()))
+ q->viewport()->update(lineRect.toRect());
painter.fillRect(lineRect, color);
}
@@ -7217,10 +7214,20 @@ void TextEditorWidget::encourageApply()
void TextEditorWidget::showEvent(QShowEvent* e)
{
triggerPendingUpdates();
+ // QPlainTextEdit::showEvent scrolls to make the cursor visible on first show
+ // which we don't want, since we restore previous states when
+ // opening editors, and when splitting/duplicating.
+ // So restore the previous state after that.
+ QByteArray state;
+ if (d->m_wasNotYetShown)
+ state = saveState();
QPlainTextEdit::showEvent(e);
+ if (d->m_wasNotYetShown) {
+ restoreState(state);
+ d->m_wasNotYetShown = false;
+ }
}
-
void TextEditorWidgetPrivate::applyFontSettingsDelayed()
{
m_fontSettingsNeedsApply = true;