From 4e8ef4cf4deaefa8d9f4383e937cb10ea6958a92 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Thu, 14 Nov 2019 00:17:21 -0800 Subject: [PATCH] Remove gating for inMemoryResourcePrefix Some users are setting weird errors related to untitled TS files. In some of these cases (such as https://github.com/microsoft/TypeScript/issues/35091) we see a untitled file being sent to the tsserver without the `inMemoryResourcePrefix`. I can't figure out how to get into this state but am removing the gating that *could* perhaps cause use not to set `inMemoryResourcePrefix`. This gating targets TS 2.7 or older, which telemetry shows very, very few users are still enabling in their workspaces --- .../src/typescriptServiceClient.ts | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/extensions/typescript-language-features/src/typescriptServiceClient.ts b/extensions/typescript-language-features/src/typescriptServiceClient.ts index 51bf7d9568d..e376922dbaf 100644 --- a/extensions/typescript-language-features/src/typescriptServiceClient.ts +++ b/extensions/typescript-language-features/src/typescriptServiceClient.ts @@ -82,7 +82,8 @@ namespace ServerState { export default class TypeScriptServiceClient extends Disposable implements ITypeScriptServiceClient { private static readonly WALK_THROUGH_SNIPPET_SCHEME_COLON = `${fileSchemes.walkThroughSnippet}:`; - private pathSeparator: string; + private readonly pathSeparator: string; + private readonly inMemoryResourcePrefix = '^'; private _onReady?: { promise: Promise; resolve: () => void; reject: () => void; }; private _configuration: TypeScriptServiceConfiguration; @@ -591,23 +592,18 @@ export default class TypeScriptServiceClient extends Disposable implements IType return this.toPath(document.uri) || undefined; } - private get inMemoryResourcePrefix(): string { - return this.apiVersion.gte(API.v270) ? '^' : ''; - } - public toResource(filepath: string): vscode.Uri { if (filepath.startsWith(TypeScriptServiceClient.WALK_THROUGH_SNIPPET_SCHEME_COLON) || (filepath.startsWith(fileSchemes.untitled + ':')) ) { let resource = vscode.Uri.parse(filepath); - if (this.inMemoryResourcePrefix) { - const dirName = path.dirname(resource.path); - const fileName = path.basename(resource.path); - if (fileName.startsWith(this.inMemoryResourcePrefix)) { - resource = resource.with({ - path: path.posix.join(dirName, fileName.slice(this.inMemoryResourcePrefix.length)) - }); - } + const dirName = path.dirname(resource.path); + const fileName = path.basename(resource.path); + if (fileName.startsWith(this.inMemoryResourcePrefix)) { + resource = resource.with({ + path: path.posix.join(dirName, fileName.slice(this.inMemoryResourcePrefix.length)) + }); } + return this.bufferSyncSupport.toVsCodeResource(resource); }