aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorVeetaha <[email protected]>2020-03-07 12:34:09 +0000
committerVeetaha <[email protected]>2020-03-07 12:34:09 +0000
commit2734ffa20c4c38f57bb6808d6cf87d0a8aaf1ea5 (patch)
tree75d0f6d9053dcdabeba6dcd2e714f21b80203dc3 /editors
parentef52fd543f4048d36e2c37281de4bc343871a62d (diff)
vscode: remove logging from inlays, run fix lint issues
Diffstat (limited to 'editors')
-rw-r--r--editors/code/src/inlay_hints.ts25
1 files changed, 7 insertions, 18 deletions
diff --git a/editors/code/src/inlay_hints.ts b/editors/code/src/inlay_hints.ts
index 6d084362d..d7fabe795 100644
--- a/editors/code/src/inlay_hints.ts
+++ b/editors/code/src/inlay_hints.ts
@@ -3,7 +3,7 @@ import * as vscode from 'vscode';
3import * as ra from './rust-analyzer-api'; 3import * as ra from './rust-analyzer-api';
4 4
5import { Ctx, Disposable } from './ctx'; 5import { Ctx, Disposable } from './ctx';
6import { sendRequestWithRetry, isRustDocument, RustDocument, RustEditor, log } from './util'; 6import { sendRequestWithRetry, isRustDocument, RustDocument, RustEditor } from './util';
7 7
8 8
9export function activateInlayHints(ctx: Ctx) { 9export function activateInlayHints(ctx: Ctx) {
@@ -86,7 +86,8 @@ class HintsUpdater implements Disposable {
86 86
87 // Set up initial cache shape 87 // Set up initial cache shape
88 ctx.visibleRustEditors.forEach(editor => self.sourceFiles.set( 88 ctx.visibleRustEditors.forEach(editor => self.sourceFiles.set(
89 editor.document.uri.toString(), { 89 editor.document.uri.toString(),
90 {
90 document: editor.document, 91 document: editor.document,
91 inlaysRequest: null, 92 inlaysRequest: null,
92 cachedDecorations: null 93 cachedDecorations: null
@@ -104,9 +105,8 @@ class HintsUpdater implements Disposable {
104 this.disposables.forEach(d => d.dispose()); 105 this.disposables.forEach(d => d.dispose());
105 } 106 }
106 107
107 onDidChangeTextDocument({contentChanges, document}: vscode.TextDocumentChangeEvent) { 108 onDidChangeTextDocument({ contentChanges, document }: vscode.TextDocumentChangeEvent) {
108 if (contentChanges.length === 0 || !isRustDocument(document)) return; 109 if (contentChanges.length === 0 || !isRustDocument(document)) return;
109 log.debug(`[inlays]: changed text doc!`);
110 this.syncCacheAndRenderHints(); 110 this.syncCacheAndRenderHints();
111 } 111 }
112 112
@@ -126,7 +126,6 @@ class HintsUpdater implements Disposable {
126 } 126 }
127 127
128 onDidChangeVisibleTextEditors() { 128 onDidChangeVisibleTextEditors() {
129 log.debug(`[inlays]: changed visible text editors`);
130 const newSourceFiles = new Map<string, RustSourceFile>(); 129 const newSourceFiles = new Map<string, RustSourceFile>();
131 130
132 // Rerendering all, even up-to-date editors for simplicity 131 // Rerendering all, even up-to-date editors for simplicity
@@ -184,11 +183,7 @@ class HintsUpdater implements Disposable {
184 return decorations; 183 return decorations;
185 } 184 }
186 185
187 lastReqId = 0;
188 private async fetchHints(file: RustSourceFile): Promise<null | ra.InlayHint[]> { 186 private async fetchHints(file: RustSourceFile): Promise<null | ra.InlayHint[]> {
189 const reqId = ++this.lastReqId;
190
191 log.debug(`[inlays]: ${reqId} requesting`);
192 file.inlaysRequest?.cancel(); 187 file.inlaysRequest?.cancel();
193 188
194 const tokenSource = new vscode.CancellationTokenSource(); 189 const tokenSource = new vscode.CancellationTokenSource();
@@ -197,18 +192,12 @@ class HintsUpdater implements Disposable {
197 const request = { textDocument: { uri: file.document.uri.toString() } }; 192 const request = { textDocument: { uri: file.document.uri.toString() } };
198 193
199 return sendRequestWithRetry(this.ctx.client, ra.inlayHints, request, tokenSource.token) 194 return sendRequestWithRetry(this.ctx.client, ra.inlayHints, request, tokenSource.token)
200 .catch(_ => { 195 .catch(_ => null)
201 log.debug(`[inlays]: ${reqId} err`);
202 return null;
203 })
204 .finally(() => { 196 .finally(() => {
205 if (file.inlaysRequest === tokenSource) { 197 if (file.inlaysRequest === tokenSource) {
206 file.inlaysRequest = null; 198 file.inlaysRequest = null;
207 log.debug(`[inlays]: ${reqId} got response!`);
208 } else {
209 log.debug(`[inlays]: ${reqId} cancelled!`);
210 } 199 }
211 }) 200 });
212 } 201 }
213} 202}
214 203
@@ -227,5 +216,5 @@ interface RustSourceFile {
227 */ 216 */
228 cachedDecorations: null | InlaysDecorations; 217 cachedDecorations: null | InlaysDecorations;
229 218
230 document: RustDocument 219 document: RustDocument;
231} 220}