Skip to content

Commit 631a445

Browse files
authored
Enable enhancedColorization by default. Fix refresh race in colorization.ts (#3770)
1 parent 9b29698 commit 631a445

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

Extension/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@
503503
"Enabled",
504504
"Disabled"
505505
],
506-
"default": "Disabled",
506+
"default": "Enabled",
507507
"description": "If enabled, code is colorized based on IntelliSense. This setting has no effect if IntelliSense is disabled.",
508508
"scope": "resource"
509509
}

Extension/src/LanguageServer/colorization.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ export class ColorizationState {
442442
this.disposeColorizationDecorations();
443443
}
444444

445-
public refresh(e: vscode.TextEditor): void {
445+
private refreshInner(e: vscode.TextEditor): void {
446446
// Clear inactive regions
447447
if (this.inactiveDecoration) {
448448
e.setDecorations(this.inactiveDecoration, []);
@@ -466,19 +466,26 @@ export class ColorizationState {
466466
}
467467
}
468468
// Apply dimming last
469-
if (settings.dimInactiveRegions && this.inactiveRanges) {
469+
if (settings.dimInactiveRegions && this.inactiveDecoration && this.inactiveRanges) {
470470
e.setDecorations(this.inactiveDecoration, this.inactiveRanges);
471471
}
472472
}
473473

474+
public refresh(e: vscode.TextEditor): void {
475+
let f: () => void = async () => {
476+
this.refreshInner(e);
477+
};
478+
this.colorizationSettings.syncWithLoadingSettings(f);
479+
}
480+
474481
public onSettingsChanged(uri: vscode.Uri): void {
475482
let f: () => void = async () => {
476483
this.disposeColorizationDecorations();
477484
let isCpp: boolean = util.isEditorFileCpp(uri.toString());
478485
this.createColorizationDecorations(isCpp);
479486
let editors: vscode.TextEditor[] = vscode.window.visibleTextEditors.filter(e => e.document.uri === uri);
480487
for (let e of editors) {
481-
this.refresh(e);
488+
this.refreshInner(e);
482489
}
483490
};
484491
this.colorizationSettings.syncWithLoadingSettings(f);
@@ -650,7 +657,7 @@ export class ColorizationState {
650657
// Apply the decorations to all *visible* text editors
651658
let editors: vscode.TextEditor[] = vscode.window.visibleTextEditors.filter(e => e.document.uri.toString() === uri);
652659
for (let e of editors) {
653-
this.refresh(e);
660+
this.refreshInner(e);
654661
}
655662
};
656663
this.colorizationSettings.syncWithLoadingSettings(f);

0 commit comments

Comments
 (0)