diff options
author | David Schulz <david.schulz@qt.io> | 2020-02-05 13:23:59 +0100 |
---|---|---|
committer | David Schulz <david.schulz@qt.io> | 2020-02-10 13:40:32 +0000 |
commit | 4ebf6981db3d2d0b434716f55d5f1ff6ac062a07 (patch) | |
tree | 450f0361c1c8c56156e7be01802733c50d8dd606 /src/plugins | |
parent | 888d804826463a4c5792bffad38d86fbffc56773 (diff) | |
download | qt-creator-4ebf6981db3d2d0b434716f55d5f1ff6ac062a07.tar.gz |
Editor: Update viewport margin if extra area width differs
Change-Id: I305bde817f70ac4b84054d04170700ef10f090cd
Fixes: QTCREATORBUG-23238
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/texteditor/texteditor.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 2a5b885aca..de81447629 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -564,7 +564,7 @@ public: void transformSelectedLines(ListTransformationMethod method); - void slotUpdateExtraAreaWidth(); + void slotUpdateExtraAreaWidth(Utils::optional<int> width = {}); void slotUpdateRequest(const QRect &r, int dy); void slotUpdateBlockNotify(const QTextBlock &); void updateTabStops(); @@ -4925,15 +4925,21 @@ int TextEditorWidget::extraAreaWidth(int *markWidthPtr) const if (d->m_codeFoldingVisible) space += foldBoxWidth(fm); + + if (viewportMargins() != QMargins{isLeftToRight() ? space : 0, 0, isLeftToRight() ? 0 : space, 0}) + d->slotUpdateExtraAreaWidth(space); + return space; } -void TextEditorWidgetPrivate::slotUpdateExtraAreaWidth() +void TextEditorWidgetPrivate::slotUpdateExtraAreaWidth(optional<int> width) { + if (!width.has_value()) + width = q->extraAreaWidth(); if (q->isLeftToRight()) - q->setViewportMargins(q->extraAreaWidth(), 0, 0, 0); + q->setViewportMargins(*width, 0, 0, 0); else - q->setViewportMargins(0, 0, q->extraAreaWidth(), 0); + q->setViewportMargins(0, 0, *width, 0); } struct Internal::ExtraAreaPaintEventData |