mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-03 15:01:57 +01:00
Add support for workspace relative tsdk settings
This commit is contained in:
@@ -36,7 +36,7 @@ export class TypeScriptVersionProvider {
|
||||
|
||||
public get globalVersion(): TypeScriptVersion | undefined {
|
||||
if (this.configuration.globalTsdk) {
|
||||
const globals = this.getTypeScriptsFromPaths(this.configuration.globalTsdk);
|
||||
const globals = this.loadVersionsFromSetting(this.configuration.globalTsdk);
|
||||
if (globals && globals.length) {
|
||||
return globals[0];
|
||||
}
|
||||
@@ -73,9 +73,26 @@ export class TypeScriptVersionProvider {
|
||||
}
|
||||
|
||||
private get localTsdkVersions(): TypeScriptVersion[] {
|
||||
return this.configuration.localTsdk
|
||||
? this.getTypeScriptsFromPaths(this.configuration.localTsdk)
|
||||
: [];
|
||||
const localTsdk = this.configuration.localTsdk;
|
||||
return localTsdk ? this.loadVersionsFromSetting(localTsdk) : [];
|
||||
}
|
||||
|
||||
private loadVersionsFromSetting(tsdkPathSetting: string): TypeScriptVersion[] {
|
||||
if (path.isAbsolute(tsdkPathSetting)) {
|
||||
return this.getTypeScriptsFromPaths(tsdkPathSetting);
|
||||
}
|
||||
|
||||
for (const root of workspace.workspaceFolders || []) {
|
||||
const rootPrefix = `./${root.name}/`;
|
||||
const winRootPrefix = `.\\${root.name}\\`;
|
||||
|
||||
if (tsdkPathSetting.startsWith(rootPrefix) || tsdkPathSetting.startsWith(winRootPrefix)) {
|
||||
const workspacePath = path.join(root.uri.fsPath, tsdkPathSetting.replace(rootPrefix, ''));
|
||||
return this.getTypeScriptsFromPaths(workspacePath);
|
||||
}
|
||||
}
|
||||
|
||||
return this.getTypeScriptsFromPaths(tsdkPathSetting);
|
||||
}
|
||||
|
||||
private get localNodeModulesVersions(): TypeScriptVersion[] {
|
||||
|
||||
Reference in New Issue
Block a user