diff --git a/src/server/features/bufferSyncSupport.ts b/src/server/features/bufferSyncSupport.ts index 7869084..5edd84b 100644 --- a/src/server/features/bufferSyncSupport.ts +++ b/src/server/features/bufferSyncSupport.ts @@ -101,7 +101,7 @@ export default class BufferSyncSupport { } } if (this.client.apiVersion.gte(API.v230)) { - args.projectRootPath = this.client.getWorkspaceRootForResource(document.uri) + args.projectRootPath = this.client.getProjectRootPath(document.uri) } this.client.execute('open', args, false) // tslint:disable-line diff --git a/src/server/typescriptService.ts b/src/server/typescriptService.ts index 88f8ff7..ca78276 100644 --- a/src/server/typescriptService.ts +++ b/src/server/typescriptService.ts @@ -39,7 +39,7 @@ export interface ITypeScriptServiceClient { onTypesInstallerInitializationFailed: Event readonly logger: Logger - getWorkspaceRootForResource(uri: string): string + getProjectRootPath(uri: string): string normalizePath(resource: Uri): string | null asUrl(filepath: string): Uri toPath(uri: string): string diff --git a/src/server/typescriptServiceClient.ts b/src/server/typescriptServiceClient.ts index 1e8cf95..1761df5 100644 --- a/src/server/typescriptServiceClient.ts +++ b/src/server/typescriptServiceClient.ts @@ -318,7 +318,6 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient workspace.showMessage(`Can not find tsserver, run ':CocInstall coc-tsserver' to fix it!`, 'error') return } - workspace.showMessage(`Using tsserver from: ${currentVersion.path}`) // tslint:disable-line this._apiVersion = currentVersion.version this.versionStatus.onDidChangeTypeScriptVersion(currentVersion) this.requestQueue = new RequestQueue() @@ -813,11 +812,11 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient return args } - public getWorkspaceRootForResource(uri: string): string { + public getProjectRootPath(uri: string): string { let u = Uri.parse(uri) if (u.scheme != 'file') return workspace.root - let res = findUp.sync(['package.json', '.vim', '.git', '.hg'], { cwd: path.dirname(u.fsPath) }) - return res ? path.dirname(res) : null + let res = findUp.sync(['tsconfig.json', 'jsconfig.json', 'package.json'], { cwd: path.dirname(u.fsPath) }) + return res ? path.dirname(res) : workspace.rootPath } }