@@ -165,6 +165,7 @@ export interface Client {
165165 Name : string ;
166166 TrackedDocuments : Set < vscode . TextDocument > ;
167167 onDidChangeSettings ( ) : void ;
168+ onDidChangeVisibleTextEditors ( editors : vscode . TextEditor [ ] ) : void ;
168169 takeOwnership ( document : vscode . TextDocument ) : void ;
169170 requestGoToDeclaration ( ) : Thenable < void > ;
170171 requestSwitchHeaderSource ( rootPath : string , fileName : string ) : Thenable < string > ;
@@ -204,7 +205,7 @@ class DefaultClient implements Client {
204205 private crashTimes : number [ ] = [ ] ;
205206 private failureMessageShown = new PersistentState < boolean > ( "DefaultClient.failureMessageShown" , false ) ;
206207 private isSupported : boolean = true ;
207- private inactiveRegionsDecoration : vscode . TextEditorDecorationType ;
208+ private inactiveRegionsDecorations = new Map < string , [ vscode . TextEditorDecorationType , vscode . Range [ ] ] > ( ) ;
208209
209210 // The "model" that is displayed via the UI (status bar).
210211 private model : ClientModel = {
@@ -635,15 +636,23 @@ class DefaultClient implements Client {
635636 } ;
636637
637638 // Recycle the active text decorations when we receive a new set of inactive regions
638- if ( this . inactiveRegionsDecoration !== undefined ) {
639- this . inactiveRegionsDecoration . dispose ( ) ;
639+ if ( this . inactiveRegionsDecorations . has ( params . uri ) ) {
640+ this . inactiveRegionsDecorations . get ( params . uri ) [ 0 ] . dispose ( ) ;
640641 }
641- this . inactiveRegionsDecoration = vscode . window . createTextEditorDecorationType ( renderOptions ) ;
642+ let decoration : vscode . TextEditorDecorationType = vscode . window . createTextEditorDecorationType ( renderOptions ) ;
643+ this . inactiveRegionsDecorations . set ( params . uri , [ decoration , params . ranges ] ) ;
642644
643645 // Apply the decorations to all relevant editors
644646 let editors : vscode . TextEditor [ ] = vscode . window . visibleTextEditors . filter ( e => e . document . uri . toString ( ) === params . uri ) ;
645647 for ( let e of editors ) {
646- e . setDecorations ( this . inactiveRegionsDecoration , params . ranges ) ;
648+ e . setDecorations ( this . inactiveRegionsDecorations . get ( params . uri ) [ 0 ] , params . ranges ) ;
649+ }
650+ }
651+
652+ public onDidChangeVisibleTextEditors ( editors : vscode . TextEditor [ ] ) : void {
653+ for ( let e of editors ) {
654+ let value : [ vscode . TextEditorDecorationType , vscode . Range [ ] ] = this . inactiveRegionsDecorations . get ( e . document . uri . toString ( ) ) ;
655+ e . setDecorations ( value [ 0 ] , value [ 1 ] ) ;
647656 }
648657 }
649658
@@ -836,6 +845,7 @@ class NullClient implements Client {
836845 Name : string = "(empty)" ;
837846 TrackedDocuments = new Set < vscode . TextDocument > ( ) ;
838847 onDidChangeSettings ( ) : void { }
848+ onDidChangeVisibleTextEditors ( editors : vscode . TextEditor [ ] ) : void { }
839849 takeOwnership ( document : vscode . TextDocument ) : void { }
840850 requestGoToDeclaration ( ) : Thenable < void > { return Promise . resolve ( ) ; }
841851 requestSwitchHeaderSource ( rootPath : string , fileName : string ) : Thenable < string > { return Promise . resolve ( "" ) ; }
0 commit comments