diff --git a/src/server/features/bufferSyncSupport.ts b/src/server/features/bufferSyncSupport.ts index 5edd84b..d063aa4 100644 --- a/src/server/features/bufferSyncSupport.ts +++ b/src/server/features/bufferSyncSupport.ts @@ -101,7 +101,8 @@ export default class BufferSyncSupport { } } if (this.client.apiVersion.gte(API.v230)) { - args.projectRootPath = this.client.getProjectRootPath(document.uri) + let root = this.client.getProjectRootPath(document.uri) + if (root) args.projectRootPath = root } this.client.execute('open', args, false) // tslint:disable-line diff --git a/src/server/typescriptServiceClient.ts b/src/server/typescriptServiceClient.ts index b7e711b..96ed13d 100644 --- a/src/server/typescriptServiceClient.ts +++ b/src/server/typescriptServiceClient.ts @@ -816,8 +816,8 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient let u = Uri.parse(uri) if (u.scheme != 'file') return workspace.cwd if (u.fsPath.startsWith(workspace.root) && workspace.root != os.homedir()) return workspace.cwd - let res = findUp.sync(['package.json', 'tsconfig.json', 'jsconfig.json'], { cwd: path.dirname(u.fsPath) }) - return res ? path.dirname(res) : workspace.rootPath + let res = findUp.sync(['tsconfig.json', 'jsconfig.json'], { cwd: path.dirname(u.fsPath) }) + return res ? path.dirname(res) : workspace.cwd } }