use workspace root as project root when possible

This commit is contained in:
chemzqm 2019-01-25 20:28:12 +08:00
parent b1fcf886cc
commit ed95234b22

View file

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