Skip to content

Commit 6f9a8e1

Browse files
committed
Modify light theme coloration; Add decorationRangePair interface; Guard against undefined return value
1 parent 4ab47bd commit 6f9a8e1

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

Extension/src/LanguageServer/client.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { createProtocolFilter } from './protocolFilter';
2121
import { DataBinding } from './dataBinding';
2222
import minimatch = require("minimatch");
2323
import * as logger from '../logger';
24+
import { deactivate } from './extension';
2425

2526
let ui: UI;
2627

@@ -193,6 +194,11 @@ export function createNullClient(): Client {
193194
return new NullClient();
194195
}
195196

197+
interface decorationRangesPair {
198+
decoration: vscode.TextEditorDecorationType;
199+
ranges: vscode.Range[];
200+
}
201+
196202
class DefaultClient implements Client {
197203
private languageClient: LanguageClient; // The "client" that launches and communicates with our language "server" process.
198204
private disposables: vscode.Disposable[] = [];
@@ -205,7 +211,7 @@ class DefaultClient implements Client {
205211
private crashTimes: number[] = [];
206212
private failureMessageShown = new PersistentState<boolean>("DefaultClient.failureMessageShown", false);
207213
private isSupported: boolean = true;
208-
private inactiveRegionsDecorations = new Map<string, [vscode.TextEditorDecorationType, vscode.Range[]]>();
214+
private inactiveRegionsDecorations = new Map<string, decorationRangesPair>();
209215

210216
// The "model" that is displayed via the UI (status bar).
211217
private model: ClientModel = {
@@ -393,8 +399,10 @@ class DefaultClient implements Client {
393399
public onDidChangeVisibleTextEditors(editors: vscode.TextEditor[]): void {
394400
//Apply text decorations to inactive regions
395401
for (let e of editors) {
396-
let valuePair: [vscode.TextEditorDecorationType, vscode.Range[]] = this.inactiveRegionsDecorations.get(e.document.uri.toString());
397-
e.setDecorations(valuePair[0], valuePair[1]); // VSCode clears the decorations when the text editor becomes invisible
402+
let valuePair: decorationRangesPair = this.inactiveRegionsDecorations.get(e.document.uri.toString());
403+
//if (valuePair !== undefined) {
404+
e.setDecorations(valuePair.decoration, valuePair.ranges); // VSCode clears the decorations when the text editor becomes invisible
405+
//}
398406
}
399407
}
400408

@@ -639,21 +647,25 @@ class DefaultClient implements Client {
639647

640648
private updateInactiveRegions(params: InactiveRegionParams): void {
641649
let renderOptions: vscode.DecorationRenderOptions = {
642-
light: { color: "rgba(125,125,125,1.0)" },
650+
light: { color: "rgba(175,175,175,1.0)" },
643651
dark: { color: "rgba(155,155,155,1.0)" }
644652
};
645653
let decoration: vscode.TextEditorDecorationType = vscode.window.createTextEditorDecorationType(renderOptions);
646654

647655
// Recycle the active text decorations when we receive a new set of inactive regions
648-
let valuePair: [vscode.TextEditorDecorationType, vscode.Range[]] = this.inactiveRegionsDecorations.get(params.uri);
656+
let valuePair: decorationRangesPair = this.inactiveRegionsDecorations.get(params.uri);
649657
if (valuePair !== undefined) {
650658
// Disposing of and resetting the decoration will undo previously applied text decorations
651-
valuePair[0].dispose();
652-
valuePair[0] = decoration;
659+
valuePair.decoration.dispose();
660+
valuePair.decoration = decoration;
653661

654-
valuePair[1] = params.ranges; // As vscode.TextEditor.setDecorations only applies to visible editors, we must cache the range for when another editor becomes visible
662+
valuePair.ranges = params.ranges; // As vscode.TextEditor.setDecorations only applies to visible editors, we must cache the range for when another editor becomes visible
655663
} else { // The entry does not exist. Make a new one
656-
this.inactiveRegionsDecorations.set(params.uri, [decoration, params.ranges]);
664+
let toInsert: decorationRangesPair = {
665+
decoration: decoration,
666+
ranges: params.ranges
667+
};
668+
this.inactiveRegionsDecorations.set(params.uri, toInsert);
657669
}
658670

659671
// Apply the decorations to all *visible* text editors

0 commit comments

Comments
 (0)