@@ -32,24 +32,20 @@ export function activateColorDecorations(decoratorProvider: (uri: string) => The
3232
3333 let pendingUpdateRequests : { [ key : string ] : NodeJS . Timer ; } = { } ;
3434
35- // we care about all visible editors
36- window . visibleTextEditors . forEach ( editor => {
37- if ( editor . document ) {
38- triggerUpdateDecorations ( editor . document ) ;
39- }
40- } ) ;
41- // to get visible one has to become active
42- window . onDidChangeActiveTextEditor ( editor => {
43- if ( editor ) {
35+ window . onDidChangeVisibleTextEditors ( editors => {
36+ for ( let editor of editors ) {
4437 triggerUpdateDecorations ( editor . document ) ;
4538 }
4639 } , null , disposables ) ;
4740
4841 workspace . onDidChangeTextDocument ( event => triggerUpdateDecorations ( event . document ) , null , disposables ) ;
49- workspace . onDidOpenTextDocument ( triggerUpdateDecorations , null , disposables ) ;
50- workspace . onDidCloseTextDocument ( triggerUpdateDecorations , null , disposables ) ;
5142
52- workspace . textDocuments . forEach ( triggerUpdateDecorations ) ;
43+ // we care about all visible editors
44+ window . visibleTextEditors . forEach ( editor => {
45+ if ( editor . document ) {
46+ triggerUpdateDecorations ( editor . document ) ;
47+ }
48+ } ) ;
5349
5450 function triggerUpdateDecorations ( document : TextDocument ) {
5551 let triggerUpdate = supportedLanguages [ document . languageId ] ;
@@ -78,6 +74,7 @@ export function activateColorDecorations(decoratorProvider: (uri: string) => The
7874 decoratorProvider ( contentUri ) . then ( ranges => {
7975 for ( let editor of window . visibleTextEditors ) {
8076 let document = editor . document ;
77+
8178 if ( document && document . version === documentVersion && contentUri === document . uri . toString ( ) ) {
8279 let decorations = ranges . slice ( 0 , MAX_DECORATORS ) . map ( range => {
8380 let color = document . getText ( range ) ;
0 commit comments