Code review fixes
This commit is contained in:
@@ -1,9 +1,5 @@
|
|||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import {
|
import { Range, TextDocumentChangeEvent, TextEditor } from 'vscode';
|
||||||
Range,
|
|
||||||
TextDocumentChangeEvent,
|
|
||||||
TextEditor
|
|
||||||
} from 'vscode';
|
|
||||||
import { TextDocumentIdentifier } from 'vscode-languageclient';
|
import { TextDocumentIdentifier } from 'vscode-languageclient';
|
||||||
import { Server } from '../server';
|
import { Server } from '../server';
|
||||||
|
|
||||||
@@ -29,7 +25,7 @@ export class HintsUpdater {
|
|||||||
public async loadHints(
|
public async loadHints(
|
||||||
editor: vscode.TextEditor | undefined
|
editor: vscode.TextEditor | undefined
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
if (this.displayHints && editor !== undefined) {
|
if (this.displayHints && editor !== undefined && this.isRustDocument(editor.document)) {
|
||||||
await this.updateDecorationsFromServer(
|
await this.updateDecorationsFromServer(
|
||||||
editor.document.uri.toString(),
|
editor.document.uri.toString(),
|
||||||
editor
|
editor
|
||||||
@@ -61,7 +57,7 @@ export class HintsUpdater {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const document = cause == null ? editor.document : cause.document;
|
const document = cause == null ? editor.document : cause.document;
|
||||||
if (document.languageId !== 'rust') {
|
if (!this.isRustDocument(document)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,6 +67,10 @@ export class HintsUpdater {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private isRustDocument(document: vscode.TextDocument): boolean {
|
||||||
|
return document && document.languageId === 'rust';
|
||||||
|
}
|
||||||
|
|
||||||
private async updateDecorationsFromServer(
|
private async updateDecorationsFromServer(
|
||||||
documentUri: string,
|
documentUri: string,
|
||||||
editor: TextEditor
|
editor: TextEditor
|
||||||
|
|||||||
@@ -152,15 +152,15 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
if (Server.config.displayInlayHints) {
|
if (Server.config.displayInlayHints) {
|
||||||
const hintsUpdater = new HintsUpdater();
|
const hintsUpdater = new HintsUpdater();
|
||||||
hintsUpdater.loadHints(vscode.window.activeTextEditor).then(() => {
|
hintsUpdater.loadHints(vscode.window.activeTextEditor).then(() => {
|
||||||
vscode.window.onDidChangeActiveTextEditor(editor =>
|
disposeOnDeactivation(vscode.window.onDidChangeActiveTextEditor(editor =>
|
||||||
hintsUpdater.loadHints(editor)
|
hintsUpdater.loadHints(editor)
|
||||||
);
|
));
|
||||||
vscode.workspace.onDidChangeTextDocument(e =>
|
disposeOnDeactivation(vscode.workspace.onDidChangeTextDocument(e =>
|
||||||
hintsUpdater.updateHints(e)
|
hintsUpdater.updateHints(e)
|
||||||
);
|
));
|
||||||
vscode.workspace.onDidChangeConfiguration(_ =>
|
disposeOnDeactivation(vscode.workspace.onDidChangeConfiguration(_ =>
|
||||||
hintsUpdater.toggleHintsDisplay(Server.config.displayInlayHints)
|
hintsUpdater.toggleHintsDisplay(Server.config.displayInlayHints)
|
||||||
);
|
));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user