From 2f14f52e24b35323081878d598465f390db1e955 Mon Sep 17 00:00:00 2001
From: Marijn Haverbeke <marijnh@gmail.com>
Date: Mon, 28 Jul 2014 11:50:40 +0200
Subject: [PATCH] Fix problem caused by ordering of scroll width measurement
 and width adjustment

Closes #2730
---
 lib/codemirror.js | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/codemirror.js b/lib/codemirror.js
index e9cfd9de..1ed13911 100644
--- a/lib/codemirror.js
+++ b/lib/codemirror.js
@@ -2032,16 +2032,19 @@
     var cm = op.cm, display = cm.display;
     if (op.updatedDisplay) updateHeightsInViewport(cm);
 
+    op.barMeasure = measureForScrollbars(cm);
+
     // If the max line changed since it was last measured, measure it,
     // and ensure the document's width matches it.
     // updateDisplay_W2 will use these properties to do the actual resizing
     if (display.maxLineChanged && !cm.options.lineWrapping) {
-      op.adjustWidthTo = measureChar(cm, display.maxLine, display.maxLine.text.length).left;
+      op.adjustWidthTo = measureChar(cm, display.maxLine, display.maxLine.text.length).left + 3;
       op.maxScrollLeft = Math.max(0, display.sizer.offsetLeft + op.adjustWidthTo +
                                   scrollerCutOff - display.scroller.clientWidth);
+      var wDiff = op.adjustWidthTo - parseInt(display.sizer.style.minWidth || "0");
+      op.barMeasure.scrollWidth += wDiff;
     }
 
-    op.barMeasure = measureForScrollbars(cm);
     if (op.updatedDisplay || op.selectionChanged)
       op.newSelectionNodes = drawSelection(cm);
   }
-- 
GitLab