6
6
import 'vs/css!./media/diffEditor' ;
7
7
import * as nls from 'vs/nls' ;
8
8
import * as dom from 'vs/base/browser/dom' ;
9
+ import * as assert from 'vs/base/common/assert' ;
9
10
import { FastDomNode , createFastDomNode } from 'vs/base/browser/fastDomNode' ;
10
11
import { ISashEvent , IVerticalSashLayoutProvider , Sash , SashState , Orientation } from 'vs/base/browser/ui/sash/sash' ;
11
12
import { RunOnceScheduler } from 'vs/base/common/async' ;
@@ -429,23 +430,29 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
429
430
return result ;
430
431
}
431
432
432
- private _recreateOverviewRulers ( ) : void {
433
- if ( ! this . _options . renderOverviewRuler ) {
434
- return ;
435
- }
436
-
433
+ private _disposeOverviewRulers ( ) : void {
437
434
if ( this . _originalOverviewRuler ) {
438
435
this . _overviewDomElement . removeChild ( this . _originalOverviewRuler . getDomNode ( ) ) ;
439
436
this . _originalOverviewRuler . dispose ( ) ;
437
+ this . _originalOverviewRuler = null ;
440
438
}
441
- if ( this . _originalEditor . hasModel ( ) ) {
442
- this . _originalOverviewRuler = this . _originalEditor . createOverviewRuler ( 'original diffOverviewRuler' ) ! ;
443
- this . _overviewDomElement . appendChild ( this . _originalOverviewRuler . getDomNode ( ) ) ;
444
- }
445
-
446
439
if ( this . _modifiedOverviewRuler ) {
447
440
this . _overviewDomElement . removeChild ( this . _modifiedOverviewRuler . getDomNode ( ) ) ;
448
441
this . _modifiedOverviewRuler . dispose ( ) ;
442
+ this . _modifiedOverviewRuler = null ;
443
+ }
444
+ }
445
+
446
+ private _createOverviewRulers ( ) : void {
447
+ if ( ! this . _options . renderOverviewRuler ) {
448
+ return ;
449
+ }
450
+
451
+ assert . ok ( ! this . _originalOverviewRuler && ! this . _modifiedOverviewRuler ) ;
452
+
453
+ if ( this . _originalEditor . hasModel ( ) ) {
454
+ this . _originalOverviewRuler = this . _originalEditor . createOverviewRuler ( 'original diffOverviewRuler' ) ! ;
455
+ this . _overviewDomElement . appendChild ( this . _originalOverviewRuler . getDomNode ( ) ) ;
449
456
}
450
457
if ( this . _modifiedEditor . hasModel ( ) ) {
451
458
this . _modifiedOverviewRuler = this . _modifiedEditor . createOverviewRuler ( 'modified diffOverviewRuler' ) ! ;
@@ -794,6 +801,8 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
794
801
// Remove all view zones & decorations
795
802
this . _cleanViewZonesAndDecorations ( ) ;
796
803
804
+ this . _disposeOverviewRulers ( ) ;
805
+
797
806
// Update code editor models
798
807
this . _originalEditor . setModel ( model ? model . original : null ) ;
799
808
this . _modifiedEditor . setModel ( model ? model . modified : null ) ;
@@ -812,7 +821,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
812
821
this . _setState ( editorBrowser . DiffEditorState . Idle ) ;
813
822
814
823
if ( model ) {
815
- this . _recreateOverviewRulers ( ) ;
824
+ this . _createOverviewRulers ( ) ;
816
825
817
826
// Begin comparing
818
827
this . _beginUpdateDecorations ( ) ;
0 commit comments