diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp
index 278ea7f0f2062530762f4f967a40fee4090f4e48..8471ec947b989b77f2cb37590fa3ebbb2084a55e 100644
--- a/src/plugins/texteditor/basetexteditor.cpp
+++ b/src/plugins/texteditor/basetexteditor.cpp
@@ -1995,6 +1995,9 @@ void BaseTextEditor::paintEvent(QPaintEvent *e)
                              d->m_ifdefedOutFormat.background());
     }
 
+    // Set a brush origin so that the WaveUnderline knows where the wave started
+    painter.setBrushOrigin(offset);
+
 //    // keep right margin clean from full-width selection
 //    int maxX = offset.x() + qMax((qreal)viewportRect.width(), documentLayout->documentSize().width())
 //               - doc->documentMargin();