aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2019-07-25 13:17:37 +0100
committerKirill Bulatov <[email protected]>2019-07-25 13:43:35 +0100
commit02f18abc559930e5efec5af1ec4f3a7dbb8b4429 (patch)
tree99794b1ec98b9fb49c404df74bee5bea3574c33b /editors/code/src
parentbd904247bad2d213c25c0649ebd5e7a31e97135a (diff)
Code review fixes
Diffstat (limited to 'editors/code/src')
-rw-r--r--editors/code/src/commands/inlay_hints.ts14
-rw-r--r--editors/code/src/extension.ts12
2 files changed, 13 insertions, 13 deletions
diff --git a/editors/code/src/commands/inlay_hints.ts b/editors/code/src/commands/inlay_hints.ts
index 0ce3edcbf..ba9966161 100644
--- a/editors/code/src/commands/inlay_hints.ts
+++ b/editors/code/src/commands/inlay_hints.ts
@@ -1,9 +1,5 @@
1import * as vscode from 'vscode'; 1import * as vscode from 'vscode';
2import { 2import { Range, TextDocumentChangeEvent, TextEditor } from 'vscode';
3 Range,
4 TextDocumentChangeEvent,
5 TextEditor
6} from 'vscode';
7import { TextDocumentIdentifier } from 'vscode-languageclient'; 3import { TextDocumentIdentifier } from 'vscode-languageclient';
8import { Server } from '../server'; 4import { Server } from '../server';
9 5
@@ -29,7 +25,7 @@ export class HintsUpdater {
29 public async loadHints( 25 public async loadHints(
30 editor: vscode.TextEditor | undefined 26 editor: vscode.TextEditor | undefined
31 ): Promise<void> { 27 ): Promise<void> {
32 if (this.displayHints && editor !== undefined) { 28 if (this.displayHints && editor !== undefined && this.isRustDocument(editor.document)) {
33 await this.updateDecorationsFromServer( 29 await this.updateDecorationsFromServer(
34 editor.document.uri.toString(), 30 editor.document.uri.toString(),
35 editor 31 editor
@@ -61,7 +57,7 @@ export class HintsUpdater {
61 return; 57 return;
62 } 58 }
63 const document = cause == null ? editor.document : cause.document; 59 const document = cause == null ? editor.document : cause.document;
64 if (document.languageId !== 'rust') { 60 if (!this.isRustDocument(document)) {
65 return; 61 return;
66 } 62 }
67 63
@@ -71,6 +67,10 @@ export class HintsUpdater {
71 ); 67 );
72 } 68 }
73 69
70 private isRustDocument(document: vscode.TextDocument): boolean {
71 return document && document.languageId === 'rust';
72 }
73
74 private async updateDecorationsFromServer( 74 private async updateDecorationsFromServer(
75 documentUri: string, 75 documentUri: string,
76 editor: TextEditor 76 editor: TextEditor
diff --git a/editors/code/src/extension.ts b/editors/code/src/extension.ts
index 2ec3a2b35..9bee75394 100644
--- a/editors/code/src/extension.ts
+++ b/editors/code/src/extension.ts
@@ -152,15 +152,15 @@ export function activate(context: vscode.ExtensionContext) {
152 if (Server.config.displayInlayHints) { 152 if (Server.config.displayInlayHints) {
153 const hintsUpdater = new HintsUpdater(); 153 const hintsUpdater = new HintsUpdater();
154 hintsUpdater.loadHints(vscode.window.activeTextEditor).then(() => { 154 hintsUpdater.loadHints(vscode.window.activeTextEditor).then(() => {
155 vscode.window.onDidChangeActiveTextEditor(editor => 155 disposeOnDeactivation(vscode.window.onDidChangeActiveTextEditor(editor =>
156 hintsUpdater.loadHints(editor) 156 hintsUpdater.loadHints(editor)
157 ); 157 ));
158 vscode.workspace.onDidChangeTextDocument(e => 158 disposeOnDeactivation(vscode.workspace.onDidChangeTextDocument(e =>
159 hintsUpdater.updateHints(e) 159 hintsUpdater.updateHints(e)
160 ); 160 ));
161 vscode.workspace.onDidChangeConfiguration(_ => 161 disposeOnDeactivation(vscode.workspace.onDidChangeConfiguration(_ =>
162 hintsUpdater.toggleHintsDisplay(Server.config.displayInlayHints) 162 hintsUpdater.toggleHintsDisplay(Server.config.displayInlayHints)
163 ); 163 ));
164 }); 164 });
165 } 165 }
166} 166}