Skip to content

Commit

Permalink
Prevent corrupted measurements due to vanishing/appearing scrollbar
Browse files Browse the repository at this point in the history
Issue #1787
  • Loading branch information
marijnh committed Sep 6, 2013
1 parent 30a9ee5 commit c8c7fc1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/codemirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ window.CodeMirror = (function() {

if (mac_geLion && scrollbarWidth(d.measure) === 0)
d.scrollbarV.style.minWidth = d.scrollbarH.style.minHeight = mac_geMountainLion ? "18px" : "12px";
return needsV;
}

function visibleLines(display, doc, viewPort) {
Expand Down Expand Up @@ -410,11 +411,13 @@ window.CodeMirror = (function() {
var oldFrom = cm.display.showingFrom, oldTo = cm.display.showingTo, updated;
var visible = visibleLines(cm.display, cm.doc, viewPort);
for (;;) {
var hadVScroll = cm.display.scroller.scrollHeight > cm.display.scroller.clientHeight + 1;
if (!updateDisplayInner(cm, changes, visible, forced)) break;
forced = false;
updated = true;
changes = [];
updateSelection(cm);
updateScrollbars(cm);
if (updateScrollbars(cm) != hadVScroll) continue;
forced = false;

// Clip forced viewport to actual scrollable area
if (viewPort)
Expand All @@ -423,7 +426,6 @@ window.CodeMirror = (function() {
visible = visibleLines(cm.display, cm.doc, viewPort);
if (visible.from >= cm.display.showingFrom && visible.to <= cm.display.showingTo)
break;
changes = [];
}

if (updated) {
Expand Down

0 comments on commit c8c7fc1

Please sign in to comment.