Editor: Update viewport margin if extra area width differs

Change-Id: I305bde817f70ac4b84054d04170700ef10f090cd
Fixes: QTCREATORBUG-23238
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2020-02-05 13:23:59 +01:00
parent 888d804826
commit 4ebf6981db

View File

@@ -564,7 +564,7 @@ public:
void transformSelectedLines(ListTransformationMethod method); void transformSelectedLines(ListTransformationMethod method);
void slotUpdateExtraAreaWidth(); void slotUpdateExtraAreaWidth(Utils::optional<int> width = {});
void slotUpdateRequest(const QRect &r, int dy); void slotUpdateRequest(const QRect &r, int dy);
void slotUpdateBlockNotify(const QTextBlock &); void slotUpdateBlockNotify(const QTextBlock &);
void updateTabStops(); void updateTabStops();
@@ -4925,15 +4925,21 @@ int TextEditorWidget::extraAreaWidth(int *markWidthPtr) const
if (d->m_codeFoldingVisible) if (d->m_codeFoldingVisible)
space += foldBoxWidth(fm); space += foldBoxWidth(fm);
if (viewportMargins() != QMargins{isLeftToRight() ? space : 0, 0, isLeftToRight() ? 0 : space, 0})
d->slotUpdateExtraAreaWidth(space);
return space; return space;
} }
void TextEditorWidgetPrivate::slotUpdateExtraAreaWidth() void TextEditorWidgetPrivate::slotUpdateExtraAreaWidth(optional<int> width)
{ {
if (!width.has_value())
width = q->extraAreaWidth();
if (q->isLeftToRight()) if (q->isLeftToRight())
q->setViewportMargins(q->extraAreaWidth(), 0, 0, 0); q->setViewportMargins(*width, 0, 0, 0);
else else
q->setViewportMargins(0, 0, q->extraAreaWidth(), 0); q->setViewportMargins(0, 0, *width, 0);
} }
struct Internal::ExtraAreaPaintEventData struct Internal::ExtraAreaPaintEventData