提交 0f5b2d14 编写于 作者: P Prabhanjan S Koushik 提交者: Matt Bierner

Fix #64253 - Support ~/ paths for typescript.tsdk (#64892)

* fix-64253 Added fixPathPrefixes

* fix-64253 Removed  and handled ~/path
上级 a87dc2b6
......@@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import * as arrays from './arrays';
import * as os from 'os';
export enum TsServerLogLevel {
Off,
......@@ -83,10 +84,21 @@ export class TypeScriptServiceConfiguration {
&& arrays.equals(this.tsServerPluginPaths, other.tsServerPluginPaths);
}
private static fixPathPrefixes(inspectValue: string): string {
const pathPrefixes = ['~/'];
for (const pathPrefix of pathPrefixes) {
if (inspectValue.startsWith(pathPrefix)) {
const homedir = os.homedir().concat('/');
return inspectValue.replace(pathPrefix, homedir);
}
}
return inspectValue;
}
private static extractGlobalTsdk(configuration: vscode.WorkspaceConfiguration): string | null {
const inspect = configuration.inspect('typescript.tsdk');
if (inspect && typeof inspect.globalValue === 'string') {
return inspect.globalValue;
return this.fixPathPrefixes(inspect.globalValue);
}
return null;
}
......@@ -94,7 +106,7 @@ export class TypeScriptServiceConfiguration {
private static extractLocalTsdk(configuration: vscode.WorkspaceConfiguration): string | null {
const inspect = configuration.inspect('typescript.tsdk');
if (inspect && typeof inspect.workspaceValue === 'string') {
return inspect.workspaceValue;
return this.fixPathPrefixes(inspect.workspaceValue);
}
return null;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册