Skip to content

Commit 0bdd303

Browse files
committed
Add notification for inactive regions; Respond by changing text color
1 parent 6c21e54 commit 0bdd303

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Extension/src/LanguageServer/client.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ interface OutputNotificationBody {
6969
output: string;
7070
}
7171

72+
interface InactiveRegionParams {
73+
uri: string;
74+
ranges: vscode.Range[];
75+
}
76+
7277
// Requests
7378
const NavigationListRequest: RequestType<TextDocumentIdentifier, string, void, void> = new RequestType<TextDocumentIdentifier, string, void, void>('cpptools/requestNavigationList');
7479
const GoToDeclarationRequest: RequestType<void, void, void, void> = new RequestType<void, void, void, void>('cpptools/goToDeclaration');
@@ -97,6 +102,7 @@ const ReportTagParseStatusNotification: NotificationType<ReportStatusNotificatio
97102
const ReportStatusNotification: NotificationType<ReportStatusNotificationBody, void> = new NotificationType<ReportStatusNotificationBody, void>('cpptools/reportStatus');
98103
const DebugProtocolNotification: NotificationType<OutputNotificationBody, void> = new NotificationType<OutputNotificationBody, void>('cpptools/debugProtocol');
99104
const DebugLogNotification: NotificationType<OutputNotificationBody, void> = new NotificationType<OutputNotificationBody, void>('cpptools/debugLog');
105+
const InactiveRegionNotification: NotificationType<InactiveRegionParams, void> = new NotificationType<InactiveRegionParams, void>('cpptools/inactiveRegions');
100106

101107
const maxSettingLengthForTelemetry: number = 50;
102108
let previousCppSettings: { [key: string]: any } = {};
@@ -434,6 +440,7 @@ class DefaultClient implements Client {
434440
this.languageClient.onNotification(ReportNavigationNotification, (e) => this.navigate(e));
435441
this.languageClient.onNotification(ReportStatusNotification, (e) => this.updateStatus(e));
436442
this.languageClient.onNotification(ReportTagParseStatusNotification, (e) => this.updateTagParseStatus(e));
443+
this.languageClient.onNotification(InactiveRegionNotification, (e) => this.updateInactiveRegions(e));
437444
this.setupOutputHandlers();
438445
}
439446

@@ -620,6 +627,16 @@ class DefaultClient implements Client {
620627
this.model.tagParserStatus.Value = notificationBody.status;
621628
}
622629

630+
private updateInactiveRegions(params: InactiveRegionParams): void {
631+
let renderOptions: vscode.DecorationRenderOptions = {
632+
color: "rgba(255,0,255,0.5)"
633+
};
634+
let textEditorDecoration = vscode.window.createTextEditorDecorationType(renderOptions);
635+
636+
let editor = vscode.window.visibleTextEditors.find(e => e.document.uri.toString() == params.uri); // document.uri == params.uri
637+
editor.setDecorations(textEditorDecoration, params.ranges);
638+
}
639+
623640
/*********************************************
624641
* requests to the language server
625642
*********************************************/

0 commit comments

Comments
 (0)