Use most broad root for typescript project root in multiroot. Fixes #30163
This commit is contained in:
parent
2ebb4fcead
commit
ac8f47b193
2 changed files with 10 additions and 9 deletions
|
@ -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> {
|
||||
|
|
Loading…
Reference in a new issue