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

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

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