Code review fixes

This commit is contained in:
Kirill Bulatov 2019-07-25 15:17:37 +03:00
parent bd904247ba
commit 02f18abc55
2 changed files with 13 additions and 13 deletions

View File

@ -1,9 +1,5 @@
import * as vscode from 'vscode';
import {
Range,
TextDocumentChangeEvent,
TextEditor
} from 'vscode';
import { Range, TextDocumentChangeEvent, TextEditor } from 'vscode';
import { TextDocumentIdentifier } from 'vscode-languageclient';
import { Server } from '../server';
@ -29,7 +25,7 @@ export class HintsUpdater {
public async loadHints(
editor: vscode.TextEditor | undefined
): Promise<void> {
if (this.displayHints && editor !== undefined) {
if (this.displayHints && editor !== undefined && this.isRustDocument(editor.document)) {
await this.updateDecorationsFromServer(
editor.document.uri.toString(),
editor
@ -61,7 +57,7 @@ export class HintsUpdater {
return;
}
const document = cause == null ? editor.document : cause.document;
if (document.languageId !== 'rust') {
if (!this.isRustDocument(document)) {
return;
}
@ -71,6 +67,10 @@ export class HintsUpdater {
);
}
private isRustDocument(document: vscode.TextDocument): boolean {
return document && document.languageId === 'rust';
}
private async updateDecorationsFromServer(
documentUri: string,
editor: TextEditor

View File

@ -152,15 +152,15 @@ export function activate(context: vscode.ExtensionContext) {
if (Server.config.displayInlayHints) {
const hintsUpdater = new HintsUpdater();
hintsUpdater.loadHints(vscode.window.activeTextEditor).then(() => {
vscode.window.onDidChangeActiveTextEditor(editor =>
disposeOnDeactivation(vscode.window.onDidChangeActiveTextEditor(editor =>
hintsUpdater.loadHints(editor)
);
vscode.workspace.onDidChangeTextDocument(e =>
));
disposeOnDeactivation(vscode.workspace.onDidChangeTextDocument(e =>
hintsUpdater.updateHints(e)
);
vscode.workspace.onDidChangeConfiguration(_ =>
));
disposeOnDeactivation(vscode.workspace.onDidChangeConfiguration(_ =>
hintsUpdater.toggleHintsDisplay(Server.config.displayInlayHints)
);
));
});
}
}