mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-19 11:12:43 +00:00
Code review fixes
This commit is contained in:
parent
bd904247ba
commit
02f18abc55
@ -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
|
||||
|
@ -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)
|
||||
);
|
||||
));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user