mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 12:19:20 +00:00
Use toOpenedFilePath to ensure we don't ask TS server for projectInfo if a file is not open
This commit is contained in:
@@ -58,7 +58,6 @@ class ProjectStatusCommand implements Command {
|
||||
public async execute(): Promise<void> {
|
||||
const info = this._delegate();
|
||||
|
||||
|
||||
const result = await vscode.window.showQuickPick<QuickPickItem>(coalesce([
|
||||
this.getProjectItem(info),
|
||||
this.getVersionItem(),
|
||||
@@ -169,7 +168,7 @@ export default class VersionStatus extends Disposable {
|
||||
|
||||
const doc = vscode.window.activeTextEditor.document;
|
||||
if (isTypeScriptDocument(doc)) {
|
||||
const file = this._client.normalizedPath(doc.uri);
|
||||
const file = this._client.toOpenedFilePath(doc, { suppressAlertOnFailure: true });
|
||||
if (file) {
|
||||
this._statusBarEntry.show();
|
||||
if (!this._ready) {
|
||||
|
||||
@@ -147,7 +147,9 @@ export interface ITypeScriptServiceClient {
|
||||
*
|
||||
* @return The normalized path or `undefined` if the document is not open on the server.
|
||||
*/
|
||||
toOpenedFilePath(document: vscode.TextDocument): string | undefined;
|
||||
toOpenedFilePath(document: vscode.TextDocument, options?: {
|
||||
suppressAlertOnFailure?: boolean
|
||||
}): string | undefined;
|
||||
|
||||
/**
|
||||
* Checks if `resource` has a given capability.
|
||||
|
||||
@@ -661,14 +661,14 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
return this.normalizedPath(resource);
|
||||
}
|
||||
|
||||
public toOpenedFilePath(document: vscode.TextDocument): string | undefined {
|
||||
public toOpenedFilePath(document: vscode.TextDocument, options: { suppressAlertOnFailure?: boolean } = {}): string | undefined {
|
||||
if (!this.bufferSyncSupport.ensureHasBuffer(document.uri)) {
|
||||
if (!fileSchemes.disabledSchemes.has(document.uri.scheme)) {
|
||||
if (!options.suppressAlertOnFailure && !fileSchemes.disabledSchemes.has(document.uri.scheme)) {
|
||||
console.error(`Unexpected resource ${document.uri}`);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
return this.toPath(document.uri) || undefined;
|
||||
return this.toPath(document.uri);
|
||||
}
|
||||
|
||||
public hasCapabilityForResource(resource: vscode.Uri, capability: ClientCapability): boolean {
|
||||
|
||||
Reference in New Issue
Block a user