diff options
-rw-r--r-- | src/plugins/texteditor/texteditor.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 43e125e2fc..6ff9a52607 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -651,6 +651,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; @@ -7204,10 +7205,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; |