mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 02:28:34 +01:00
Merge pull request #241742 from mjbvz/upper-walrus
Always try sending along project root paths
This commit is contained in:
@@ -191,7 +191,20 @@ class SyncedBuffer {
|
||||
}
|
||||
|
||||
private getProjectRootPath(resource: vscode.Uri): string | undefined {
|
||||
const workspaceRoot = this.client.getWorkspaceRootForResource(resource);
|
||||
let workspaceRoot = this.client.getWorkspaceRootForResource(resource);
|
||||
|
||||
// If we didn't find a real workspace, we still want to try sending along a workspace folder
|
||||
// to prevent TS from loading projects from outside of any workspace.
|
||||
// Just pick the highest level one on the same FS even though the file is outside of it
|
||||
if (!workspaceRoot && vscode.workspace.workspaceFolders) {
|
||||
for (const root of Array.from(vscode.workspace.workspaceFolders).sort((a, b) => a.uri.path.length - b.uri.path.length)) {
|
||||
if (root.uri.scheme === resource.scheme && root.uri.authority === resource.authority) {
|
||||
workspaceRoot = root.uri;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (workspaceRoot) {
|
||||
const tsRoot = this.client.toTsFilePath(workspaceRoot);
|
||||
return tsRoot?.startsWith(inMemoryResourcePrefix) ? undefined : tsRoot;
|
||||
|
||||
@@ -836,9 +836,10 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
}
|
||||
}
|
||||
|
||||
for (const root of roots.sort((a, b) => a.uri.fsPath.length - b.uri.fsPath.length)) {
|
||||
// Find the highest level workspace folder that contains the file
|
||||
for (const root of roots.sort((a, b) => a.uri.path.length - b.uri.path.length)) {
|
||||
if (root.uri.scheme === resource.scheme && root.uri.authority === resource.authority) {
|
||||
if (resource.fsPath.startsWith(root.uri.fsPath + path.sep)) {
|
||||
if (resource.path.startsWith(root.uri.path + '/')) {
|
||||
return root.uri;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user