mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-23 19:59:37 +00:00
Do not display errors in editor for cancelled js/ts code lenses
Fixes #63884 Resolving a code lenses may be cancelled if the document changes. This is normal and should not be displayed as an error in the editor
This commit is contained in:
@@ -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<T extends Proto.Response> {
|
||||
}
|
||||
|
||||
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<void>();
|
||||
|
||||
public constructor(
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user