@@ -1423,27 +1423,22 @@ export class TextModel extends Disposable implements model.ITextModel {
14231423 private _changeDecorations < T > ( ownerId : number , callback : ( changeAccessor : model . IModelDecorationsChangeAccessor ) => T ) : T | null {
14241424 let changeAccessor : model . IModelDecorationsChangeAccessor = {
14251425 addDecoration : ( range : IRange , options : model . IModelDecorationOptions ) : string => {
1426- this . _onDidChangeDecorations . fire ( ) ;
14271426 return this . _deltaDecorationsImpl ( ownerId , [ ] , [ { range : range , options : options } ] ) [ 0 ] ;
14281427 } ,
14291428 changeDecoration : ( id : string , newRange : IRange ) : void => {
1430- this . _onDidChangeDecorations . fire ( ) ;
14311429 this . _changeDecorationImpl ( id , newRange ) ;
14321430 } ,
14331431 changeDecorationOptions : ( id : string , options : model . IModelDecorationOptions ) => {
1434- this . _onDidChangeDecorations . fire ( ) ;
14351432 this . _changeDecorationOptionsImpl ( id , _normalizeOptions ( options ) ) ;
14361433 } ,
14371434 removeDecoration : ( id : string ) : void => {
1438- this . _onDidChangeDecorations . fire ( ) ;
14391435 this . _deltaDecorationsImpl ( ownerId , [ id ] , [ ] ) ;
14401436 } ,
14411437 deltaDecorations : ( oldDecorations : string [ ] , newDecorations : model . IModelDeltaDecoration [ ] ) : string [ ] => {
14421438 if ( oldDecorations . length === 0 && newDecorations . length === 0 ) {
14431439 // nothing to do
14441440 return [ ] ;
14451441 }
1446- this . _onDidChangeDecorations . fire ( ) ;
14471442 return this . _deltaDecorationsImpl ( ownerId , oldDecorations , newDecorations ) ;
14481443 }
14491444 } ;
@@ -1474,7 +1469,6 @@ export class TextModel extends Disposable implements model.ITextModel {
14741469
14751470 try {
14761471 this . _onDidChangeDecorations . beginDeferredEmit ( ) ;
1477- this . _onDidChangeDecorations . fire ( ) ;
14781472 return this . _deltaDecorationsImpl ( ownerId , oldDecorations , newDecorations ) ;
14791473 } finally {
14801474 this . _onDidChangeDecorations . endDeferredEmit ( ) ;
@@ -1622,6 +1616,7 @@ export class TextModel extends Disposable implements model.ITextModel {
16221616 this . _decorationsTree . delete ( node ) ;
16231617 node . reset ( this . getVersionId ( ) , startOffset , endOffset , range ) ;
16241618 this . _decorationsTree . insert ( node ) ;
1619+ this . _onDidChangeDecorations . checkAffectedAndFire ( node . options ) ;
16251620 }
16261621
16271622 private _changeDecorationOptionsImpl ( decorationId : string , options : ModelDecorationOptions ) : void {
@@ -1633,6 +1628,9 @@ export class TextModel extends Disposable implements model.ITextModel {
16331628 const nodeWasInOverviewRuler = ( node . options . overviewRuler && node . options . overviewRuler . color ? true : false ) ;
16341629 const nodeIsInOverviewRuler = ( options . overviewRuler && options . overviewRuler . color ? true : false ) ;
16351630
1631+ this . _onDidChangeDecorations . checkAffectedAndFire ( node . options ) ;
1632+ this . _onDidChangeDecorations . checkAffectedAndFire ( options ) ;
1633+
16361634 if ( nodeWasInOverviewRuler !== nodeIsInOverviewRuler ) {
16371635 // Delete + Insert due to an overview ruler status change
16381636 this . _decorationsTree . delete ( node ) ;
@@ -1666,6 +1664,7 @@ export class TextModel extends Disposable implements model.ITextModel {
16661664 // (2) remove the node from the tree (if it exists)
16671665 if ( node ) {
16681666 this . _decorationsTree . delete ( node ) ;
1667+ this . _onDidChangeDecorations . checkAffectedAndFire ( node . options ) ;
16691668 }
16701669 }
16711670
@@ -1688,6 +1687,7 @@ export class TextModel extends Disposable implements model.ITextModel {
16881687 node . ownerId = ownerId ;
16891688 node . reset ( versionId , startOffset , endOffset , range ) ;
16901689 node . setOptions ( options ) ;
1690+ this . _onDidChangeDecorations . checkAffectedAndFire ( options ) ;
16911691
16921692 this . _decorationsTree . insert ( node ) ;
16931693
@@ -3101,11 +3101,15 @@ export class DidChangeDecorationsEmitter extends Disposable {
31013101
31023102 private _deferredCnt : number ;
31033103 private _shouldFire : boolean ;
3104+ private _affectsMinimap : boolean ;
3105+ private _affectsOverviewRuler : boolean ;
31043106
31053107 constructor ( ) {
31063108 super ( ) ;
31073109 this . _deferredCnt = 0 ;
31083110 this . _shouldFire = false ;
3111+ this . _affectsMinimap = false ;
3112+ this . _affectsOverviewRuler = false ;
31093113 }
31103114
31113115 public beginDeferredEmit ( ) : void {
@@ -3116,13 +3120,31 @@ export class DidChangeDecorationsEmitter extends Disposable {
31163120 this . _deferredCnt -- ;
31173121 if ( this . _deferredCnt === 0 ) {
31183122 if ( this . _shouldFire ) {
3123+ const event : IModelDecorationsChangedEvent = {
3124+ affectsMinimap : this . _affectsMinimap ,
3125+ affectsOverviewRuler : this . _affectsOverviewRuler ,
3126+ } ;
31193127 this . _shouldFire = false ;
3120- this . _actual . fire ( { } ) ;
3128+ this . _affectsMinimap = false ;
3129+ this . _affectsOverviewRuler = false ;
3130+ this . _actual . fire ( event ) ;
31213131 }
31223132 }
31233133 }
31243134
3135+ public checkAffectedAndFire ( options : ModelDecorationOptions ) : void {
3136+ if ( ! this . _affectsMinimap ) {
3137+ this . _affectsMinimap = options . minimap && options . minimap . position ? true : false ;
3138+ }
3139+ if ( ! this . _affectsOverviewRuler ) {
3140+ this . _affectsOverviewRuler = options . overviewRuler && options . overviewRuler . color ? true : false ;
3141+ }
3142+ this . _shouldFire = true ;
3143+ }
3144+
31253145 public fire ( ) : void {
3146+ this . _affectsMinimap = true ;
3147+ this . _affectsOverviewRuler = true ;
31263148 this . _shouldFire = true ;
31273149 }
31283150}
0 commit comments