diff --git a/lib/codemirror.js b/lib/codemirror.js
index 9cfc6dc6bee0a2690569b0f6c02c0e952b57be59..4dc2a7eaf869f1e3f9e258770ef409d06dd41079 100644
--- a/lib/codemirror.js
+++ b/lib/codemirror.js
@@ -2042,7 +2042,7 @@
       op.maxScrollLeft = Math.max(0, display.sizer.offsetLeft + op.adjustWidthTo +
                                   scrollerCutOff - display.scroller.clientWidth);
       var prevMinWidth = display.sizer.style.minWidth;
-      if (prevMinWidth)
+      if (prevMinWidth && op.barMeasure.scrollWidth > op.barMeasure.clientWidth)
         op.barMeasure.scrollWidth += op.adjustWidthTo - parseInt(prevMinWidth);
     }