@@ -443,19 +443,6 @@ export class ColorizationState {
443
443
}
444
444
445
445
private refreshInner ( e : vscode . TextEditor ) : void {
446
-
447
- // The only way to un-apply decorators is to dispose them.
448
- // If we dispose old decorators before applying new decorators, we see a flicker on Mac,
449
- // likely due to a race with UI updates. Here we set aside the existing decorators to be
450
- // disposed of after the new decorators have been applied, so there is not a gap
451
- // in which decorators are not applied.
452
- let oldInactiveDecoration : vscode . TextEditorDecorationType = this . inactiveDecoration ;
453
- let oldDecorations : vscode . TextEditorDecorationType [ ] = this . decorations ;
454
- this . inactiveDecoration = null ;
455
- this . decorations = new Array < vscode . TextEditorDecorationType > ( TokenKind . Count ) ;
456
-
457
- this . createColorizationDecorations ( e . document . languageId === "cpp" ) ;
458
-
459
446
let settings : CppSettings = new CppSettings ( this . uri ) ;
460
447
if ( settings . enhancedColorization === "Enabled" && settings . intelliSenseEngine === "Default" ) {
461
448
for ( let i : number = 0 ; i < TokenKind . Count ; i ++ ) {
@@ -482,18 +469,6 @@ export class ColorizationState {
482
469
if ( settings . dimInactiveRegions && this . inactiveDecoration && this . inactiveRanges ) {
483
470
e . setDecorations ( this . inactiveDecoration , this . inactiveRanges ) ;
484
471
}
485
-
486
- // Dispose of the old decorators only after the new ones have been applied.
487
- if ( oldInactiveDecoration ) {
488
- oldInactiveDecoration . dispose ( ) ;
489
- }
490
- if ( oldDecorations ) {
491
- for ( let i : number = 0 ; i < TokenKind . Count ; i ++ ) {
492
- if ( oldDecorations [ i ] ) {
493
- oldDecorations [ i ] . dispose ( ) ;
494
- }
495
- }
496
- }
497
472
}
498
473
499
474
public refresh ( e : vscode . TextEditor ) : void {
@@ -672,11 +647,36 @@ export class ColorizationState {
672
647
}
673
648
}
674
649
let f : ( ) => void = async ( ) => {
650
+ // The only way to un-apply decorators is to dispose them.
651
+ // If we dispose old decorators before applying new decorators, we see a flicker on Mac,
652
+ // likely due to a race with UI updates. Here we set aside the existing decorators to be
653
+ // disposed of after the new decorators have been applied, so there is not a gap
654
+ // in which decorators are not applied.
655
+ let oldInactiveDecoration : vscode . TextEditorDecorationType = this . inactiveDecoration ;
656
+ let oldDecorations : vscode . TextEditorDecorationType [ ] = this . decorations ;
657
+ this . inactiveDecoration = null ;
658
+ this . decorations = new Array < vscode . TextEditorDecorationType > ( TokenKind . Count ) ;
659
+
660
+ let isCpp : boolean = util . isEditorFileCpp ( uri ) ;
661
+ this . createColorizationDecorations ( isCpp ) ;
662
+
675
663
// Apply the decorations to all *visible* text editors
676
664
let editors : vscode . TextEditor [ ] = vscode . window . visibleTextEditors . filter ( e => e . document . uri . toString ( ) === uri ) ;
677
665
for ( let e of editors ) {
678
666
this . refreshInner ( e ) ;
679
667
}
668
+
669
+ // Dispose of the old decorators only after the new ones have been applied.
670
+ if ( oldInactiveDecoration ) {
671
+ oldInactiveDecoration . dispose ( ) ;
672
+ }
673
+ if ( oldDecorations ) {
674
+ for ( let i : number = 0 ; i < TokenKind . Count ; i ++ ) {
675
+ if ( oldDecorations [ i ] ) {
676
+ oldDecorations [ i ] . dispose ( ) ;
677
+ }
678
+ }
679
+ }
680
680
} ;
681
681
this . colorizationSettings . syncWithLoadingSettings ( f ) ;
682
682
}
0 commit comments