From a183fa6bb190d6bacb287c3efe5da078b7b5bc74 Mon Sep 17 00:00:00 2001
From: Marijn Haverbeke <marijnh@gmail.com>
Date: Sat, 9 Aug 2014 13:07:15 +0200
Subject: [PATCH] Less fragile way to deal with updating the scrollbar during
 editor width changes

Issue #2745
---
 lib/codemirror.js | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/codemirror.js b/lib/codemirror.js
index d7eb25e79..882b17b92 100644
--- a/lib/codemirror.js
+++ b/lib/codemirror.js
@@ -2042,9 +2042,6 @@
       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 prevMinWidth = display.sizer.style.minWidth;
-      if (prevMinWidth && op.barMeasure.scrollWidth > op.barMeasure.clientWidth)
-        op.barMeasure.scrollWidth += op.adjustWidthTo - parseInt(prevMinWidth);
     }
 
     if (op.updatedDisplay || op.selectionChanged)
@@ -2077,6 +2074,9 @@
   function endOperation_finish(op) {
     var cm = op.cm, display = cm.display, doc = cm.doc;
 
+    if (op.adjustWidthTo != null && Math.abs(op.barMeasure.scrollWidth - cm.display.scroller.scrollWidth) > 1)
+      updateScrollbars(cm);
+
     if (op.updatedDisplay) postUpdateDisplay(cm, op.update);
 
     // Abort mouse wheel delta measurement, when scrolling explicitly
-- 
GitLab