Skip to content

Commit 4e8ef4c

Browse files
committed
Remove gating for inMemoryResourcePrefix
Some users are setting weird errors related to untitled TS files. In some of these cases (such as microsoft/TypeScript#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
1 parent 53210ed commit 4e8ef4c

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

extensions/typescript-language-features/src/typescriptServiceClient.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ namespace ServerState {
8282
export default class TypeScriptServiceClient extends Disposable implements ITypeScriptServiceClient {
8383
private static readonly WALK_THROUGH_SNIPPET_SCHEME_COLON = `${fileSchemes.walkThroughSnippet}:`;
8484

85-
private pathSeparator: string;
85+
private readonly pathSeparator: string;
86+
private readonly inMemoryResourcePrefix = '^';
8687

8788
private _onReady?: { promise: Promise<void>; resolve: () => void; reject: () => void; };
8889
private _configuration: TypeScriptServiceConfiguration;
@@ -591,23 +592,18 @@ export default class TypeScriptServiceClient extends Disposable implements IType
591592
return this.toPath(document.uri) || undefined;
592593
}
593594

594-
private get inMemoryResourcePrefix(): string {
595-
return this.apiVersion.gte(API.v270) ? '^' : '';
596-
}
597-
598595
public toResource(filepath: string): vscode.Uri {
599596
if (filepath.startsWith(TypeScriptServiceClient.WALK_THROUGH_SNIPPET_SCHEME_COLON) || (filepath.startsWith(fileSchemes.untitled + ':'))
600597
) {
601598
let resource = vscode.Uri.parse(filepath);
602-
if (this.inMemoryResourcePrefix) {
603-
const dirName = path.dirname(resource.path);
604-
const fileName = path.basename(resource.path);
605-
if (fileName.startsWith(this.inMemoryResourcePrefix)) {
606-
resource = resource.with({
607-
path: path.posix.join(dirName, fileName.slice(this.inMemoryResourcePrefix.length))
608-
});
609-
}
599+
const dirName = path.dirname(resource.path);
600+
const fileName = path.basename(resource.path);
601+
if (fileName.startsWith(this.inMemoryResourcePrefix)) {
602+
resource = resource.with({
603+
path: path.posix.join(dirName, fileName.slice(this.inMemoryResourcePrefix.length))
604+
});
610605
}
606+
611607
return this.bufferSyncSupport.toVsCodeResource(resource);
612608
}
613609

0 commit comments

Comments
 (0)