diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp
index 2425b4a715af8906a095d61edefdb7cc777b7dbe..a183faafbeb83cf5f8ab159e3effda0a3ff75fc2 100644
--- a/src/plugins/texteditor/basetexteditor.cpp
+++ b/src/plugins/texteditor/basetexteditor.cpp
@@ -2310,7 +2310,8 @@ void BaseTextEditor::extraAreaPaintEvent(QPaintEvent *e)
 //     if (documentLayout->doubleMarkCount)
 //         markWidth += fm.lineSpacing() / 3;
 
-    const int extraAreaWidth = d->m_extraArea->width() - collapseBoxWidth(fm);
+    const int collapseColumnWidth = d->m_codeFoldingVisible ? collapseBoxWidth(fm): 0;
+    const int extraAreaWidth = d->m_extraArea->width() - collapseColumnWidth;
 
     painter.fillRect(e->rect(), pal.color(QPalette::Base));
     painter.fillRect(e->rect().intersected(QRect(0, 0, extraAreaWidth, INT_MAX)),