@@ -401,11 +401,12 @@ window.CodeMirror = (function() {
401401
402402 // DISPLAY DRAWING
403403
404- function updateDisplay ( cm , changes , viewPort ) {
404+ function updateDisplay ( cm , changes , viewPort , forced ) {
405405 var oldFrom = cm . display . showingFrom , oldTo = cm . display . showingTo , updated ;
406406 var visible = visibleLines ( cm . display , cm . doc , viewPort ) ;
407407 for ( ; ; ) {
408- if ( ! updateDisplayInner ( cm , changes , visible ) ) break ;
408+ if ( ! updateDisplayInner ( cm , changes , visible , forced ) ) break ;
409+ forced = false ;
409410 updated = true ;
410411 updateSelection ( cm ) ;
411412 updateScrollbars ( cm ) ;
@@ -431,7 +432,7 @@ window.CodeMirror = (function() {
431432 // Uses a set of changes plus the current scroll position to
432433 // determine which DOM updates have to be made, and makes the
433434 // updates.
434- function updateDisplayInner ( cm , changes , visible ) {
435+ function updateDisplayInner ( cm , changes , visible , forced ) {
435436 var display = cm . display , doc = cm . doc ;
436437 if ( ! display . wrapper . clientWidth ) {
437438 display . showingFrom = display . showingTo = doc . first ;
@@ -440,7 +441,7 @@ window.CodeMirror = (function() {
440441 }
441442
442443 // Bail out if the visible area is already rendered and nothing changed.
443- if ( changes . length == 0 &&
444+ if ( ! forced && changes . length == 0 &&
444445 visible . from > display . showingFrom && visible . to < display . showingTo )
445446 return ;
446447
@@ -493,8 +494,7 @@ window.CodeMirror = (function() {
493494 if ( range . from >= range . to ) intact . splice ( i -- , 1 ) ;
494495 else intactLines += range . to - range . from ;
495496 }
496- if ( intactLines == to - from && from == display . showingFrom && to == display . showingTo ) {
497- updateHeightsInViewport ( cm ) ;
497+ if ( ! forced && intactLines == to - from && from == display . showingFrom && to == display . showingTo ) {
498498 updateViewOffset ( cm ) ;
499499 return ;
500500 }
@@ -1344,7 +1344,7 @@ window.CodeMirror = (function() {
13441344 newScrollPos = calculateScrollPos ( cm , coords . left , coords . top , coords . left , coords . bottom ) ;
13451345 }
13461346 if ( op . changes . length || op . forceUpdate || newScrollPos && newScrollPos . scrollTop != null ) {
1347- updated = updateDisplay ( cm , op . changes , newScrollPos && newScrollPos . scrollTop ) ;
1347+ updated = updateDisplay ( cm , op . changes , newScrollPos && newScrollPos . scrollTop , op . forceUpdate ) ;
13481348 if ( cm . display . scroller . offsetHeight ) cm . doc . scrollTop = cm . display . scroller . scrollTop ;
13491349 }
13501350 if ( ! updated && op . selectionChanged ) updateSelection ( cm ) ;
@@ -3734,7 +3734,9 @@ window.CodeMirror = (function() {
37343734 if ( node . offsetHeight != line . height ) updateLineHeight ( line , node . offsetHeight ) ;
37353735 break ;
37363736 }
3737- runInOp ( cm , function ( ) { cm . curOp . selectionChanged = true ; } ) ;
3737+ runInOp ( cm , function ( ) {
3738+ cm . curOp . selectionChanged = cm . curOp . forceUpdate = true ;
3739+ } ) ;
37383740 }
37393741 } ;
37403742
0 commit comments