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
This commit is contained in:
parent
53210edd79
commit
4e8ef4cf4d
|
@ -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<void>; 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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue