提交 1e117f41 编写于 作者: M Matt Bierner

Revert "Revert "Use special prefix to tell TS that a resource is in-memory only (#42001)""

This reverts commit 200e4013.
上级 c398a079
......@@ -48,10 +48,7 @@ class SyncedBuffer {
}
if (this.client.apiVersion.has230Features()) {
const root = this.client.getWorkspaceRootForResource(this.document.uri);
if (root) {
args.projectRootPath = root;
}
args.projectRootPath = this.client.getWorkspaceRootForResource(this.document.uri);
}
if (this.client.apiVersion.has240Features()) {
......
......@@ -578,12 +578,12 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
}
public normalizePath(resource: Uri): string | null {
if (resource.scheme === fileSchemes.walkThroughSnippet) {
return resource.toString();
}
if (resource.scheme === fileSchemes.untitled && this._apiVersion.has213Features()) {
return resource.toString();
if (this._apiVersion.has213Features()) {
if (resource.scheme === fileSchemes.walkThroughSnippet || resource.scheme === fileSchemes.untitled) {
const dirName = path.dirname(resource.path);
const fileName = this.inMemoryResourcePrefix + path.basename(resource.path);
return resource.with({ path: path.join(dirName, fileName) }).toString(true);
}
}
if (resource.scheme !== fileSchemes.file) {
......@@ -599,11 +599,24 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
return result.replace(new RegExp('\\' + this.pathSeparator, 'g'), '/');
}
private get inMemoryResourcePrefix(): string {
return this._apiVersion.has270Features() ? '^' : '';
}
public asUrl(filepath: string): Uri {
if (filepath.startsWith(TypeScriptServiceClient.WALK_THROUGH_SNIPPET_SCHEME_COLON)
|| (filepath.startsWith(fileSchemes.untitled + ':') && this._apiVersion.has213Features())
) {
return Uri.parse(filepath);
if (this._apiVersion.has213Features()) {
if (filepath.startsWith(TypeScriptServiceClient.WALK_THROUGH_SNIPPET_SCHEME_COLON) || (filepath.startsWith(fileSchemes.untitled + ':'))
) {
let resource = 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.join(dirName, fileName.slice(this.inMemoryResourcePrefix.length)) });
}
}
return resource;
}
}
return Uri.file(filepath);
}
......@@ -620,8 +633,10 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
return root.uri.fsPath;
}
}
return roots[0].uri.fsPath;
}
return roots[0].uri.fsPath;
return undefined;
}
public execute(command: string, args: any, expectsResultOrToken?: boolean | CancellationToken): Promise<any> {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册