Merge pull request #11 from jpoppe/patch-2

bug fix: workspace.cwd -> workspace.root in getProjectRootPath()
This commit is contained in:
Qiming zhao 2019-02-16 03:25:03 +08:00 committed by GitHub
commit 9e7f12842a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -815,7 +815,7 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
public getProjectRootPath(uri: string): string { public getProjectRootPath(uri: string): string {
let u = Uri.parse(uri) let u = Uri.parse(uri)
if (u.scheme != 'file') return workspace.cwd if (u.scheme != 'file') return workspace.cwd
if (u.fsPath.startsWith(workspace.root) && workspace.root != os.homedir()) return workspace.cwd if (u.fsPath.startsWith(workspace.root) && workspace.root != os.homedir()) return workspace.root
let res = findUp.sync(['tsconfig.json', 'jsconfig.json'], { cwd: path.dirname(u.fsPath) }) let res = findUp.sync(['tsconfig.json', 'jsconfig.json'], { cwd: path.dirname(u.fsPath) })
return res ? path.dirname(res) : workspace.cwd return res ? path.dirname(res) : workspace.cwd
} }