diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp
index 5ec6f11ffadcef4592db6d79483b9e088087c2fd..a3537d03af7b27f7bc0a39e64315a2889514e54f 100644
--- a/src/plugins/texteditor/basetexteditor.cpp
+++ b/src/plugins/texteditor/basetexteditor.cpp
@@ -3389,6 +3389,20 @@ void BaseTextEditor::mouseMoveEvent(QMouseEvent *e)
         viewport()->setCursor(Qt::IBeamCursor);
 }
 
+static bool handleForwardBackwardMouseButtons(QMouseEvent *e)
+{
+    if (e->button() == Qt::XButton1) {
+        Core::EditorManager::instance()->goBackInNavigationHistory();
+        return true;
+    }
+    if (e->button() == Qt::XButton2) {
+        Core::EditorManager::instance()->goForwardInNavigationHistory();
+        return true;
+    }
+
+    return false;
+}
+
 void BaseTextEditor::mousePressEvent(QMouseEvent *e)
 {
     if (e->button() == Qt::LeftButton) {
@@ -3405,6 +3419,12 @@ void BaseTextEditor::mousePressEvent(QMouseEvent *e)
         if (d->m_currentLink.isValid())
             d->m_linkPressed = true;
     }
+
+#ifdef Q_OS_LINUX
+    if (handleForwardBackwardMouseButtons(e))
+        return;
+#endif
+
     QPlainTextEdit::mousePressEvent(e);
 }
 
@@ -3423,6 +3443,11 @@ void BaseTextEditor::mouseReleaseEvent(QMouseEvent *e)
         }
     }
 
+#ifndef Q_OS_LINUX
+    if (handleForwardBackwardMouseButtons(e))
+        return;
+#endif
+
     QPlainTextEdit::mouseReleaseEvent(e);
 }