diff --git a/extensions/typescript-language-features/src/features/baseCodeLensProvider.ts b/extensions/typescript-language-features/src/features/baseCodeLensProvider.ts index ba25a71bcc6..d8cae37b818 100644 --- a/extensions/typescript-language-features/src/features/baseCodeLensProvider.ts +++ b/extensions/typescript-language-features/src/features/baseCodeLensProvider.ts @@ -4,11 +4,14 @@ *--------------------------------------------------------------------------------------------*/ import * as vscode from 'vscode'; +import * as nls from 'vscode-nls'; import * as Proto from '../protocol'; import { ITypeScriptServiceClient, ServerResponse } from '../typescriptService'; import { escapeRegExp } from '../utils/regexp'; import * as typeConverters from '../utils/typeConverters'; +const localize = nls.loadMessageBundle(); + export class ReferencesCodeLens extends vscode.CodeLens { constructor( public document: vscode.Uri, @@ -51,6 +54,18 @@ export class CachedResponse { } export abstract class TypeScriptBaseCodeLensProvider implements vscode.CodeLensProvider { + + public static readonly cancelledCommand: vscode.Command = { + // Cancellation is not an error. Just show nothing until we can properly re-compute the code lens + title: '', + command: '' + }; + + public static readonly errorCommand: vscode.Command = { + title: localize('referenceErrorLabel', 'Could not determine references'), + command: '' + }; + private onDidChangeCodeLensesEmitter = new vscode.EventEmitter(); public constructor( diff --git a/extensions/typescript-language-features/src/features/implementationsCodeLens.ts b/extensions/typescript-language-features/src/features/implementationsCodeLens.ts index d56d166e3b1..27fedfdef54 100644 --- a/extensions/typescript-language-features/src/features/implementationsCodeLens.ts +++ b/extensions/typescript-language-features/src/features/implementationsCodeLens.ts @@ -26,10 +26,9 @@ export default class TypeScriptImplementationsCodeLensProvider extends TypeScrip const args = typeConverters.Position.toFileLocationRequestArgs(codeLens.file, codeLens.range.start); const response = await this.client.execute('implementation', args, token, /* lowPriority */ true); if (response.type !== 'response' || !response.body) { - codeLens.command = { - title: localize('implementationsErrorLabel', 'Could not determine implementations'), - command: '' - }; + codeLens.command = response.type === 'cancelled' + ? TypeScriptBaseCodeLensProvider.cancelledCommand + : TypeScriptBaseCodeLensProvider.errorCommand; return codeLens; } diff --git a/extensions/typescript-language-features/src/features/referencesCodeLens.ts b/extensions/typescript-language-features/src/features/referencesCodeLens.ts index 88f96cd16c8..611d6ea5424 100644 --- a/extensions/typescript-language-features/src/features/referencesCodeLens.ts +++ b/extensions/typescript-language-features/src/features/referencesCodeLens.ts @@ -22,10 +22,9 @@ class TypeScriptReferencesCodeLensProvider extends TypeScriptBaseCodeLensProvide const args = typeConverters.Position.toFileLocationRequestArgs(codeLens.file, codeLens.range.start); const response = await this.client.execute('references', args, token, /* lowPriority */ true); if (response.type !== 'response' || !response.body) { - codeLens.command = { - title: localize('referenceErrorLabel', 'Could not determine references'), - command: '' - }; + codeLens.command = response.type === 'cancelled' + ? TypeScriptBaseCodeLensProvider.cancelledCommand + : TypeScriptBaseCodeLensProvider.errorCommand; return codeLens; }