提交 ac8f47b1 编写于 作者: M Matt Bierner

Use most broad root for typescript project root in multiroot. Fixes #30163

上级 2ebb4fce
......@@ -7,6 +7,7 @@
"license": "MIT",
"publisher": "vscode",
"aiKey": "AIF-d9b70cd4-b9f9-4d70-929b-a071c400b217",
"enableProposedApi": true,
"engines": {
"vscode": "*"
},
......
......@@ -897,19 +897,19 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
}
public getWorkspaceRootForResource(resource: Uri): string | undefined {
if (workspace.rootPath) {
return workspace.rootPath;
const roots = workspace.workspaceFolders;
if (!roots || !roots.length) {
return undefined;
}
if (workspace.workspaceFolders && workspace.workspaceFolders.length) {
if (resource.scheme === 'file') {
const found = workspace.workspaceFolders.find(root => resource.fsPath.startsWith(root.fsPath));
return found ? found.fsPath : found;
if (resource.scheme === 'file' || resource.scheme === 'untitled') {
for (const root of roots.sort((a, b) => a.fsPath.length - b.fsPath.length)) {
if (resource.fsPath.startsWith(root.fsPath)) {
return root.fsPath;
}
}
return workspace.workspaceFolders[0].fsPath;
}
return undefined;
return roots[0].fsPath;
}
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.
先完成此消息的编辑!
想要评论请 注册