diff --git a/src/server/typescriptServiceClient.ts b/src/server/typescriptServiceClient.ts index 655f53e..2d12ca7 100644 --- a/src/server/typescriptServiceClient.ts +++ b/src/server/typescriptServiceClient.ts @@ -242,7 +242,7 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient } private async startService(resendModels = false): Promise { - let currentVersion = this.versionProvider.getLocalVersion(workspace.root) + let currentVersion = this.versionProvider.getLocalVersion() if (!currentVersion || !fs.existsSync(currentVersion.tsServerPath)) { currentVersion = await this.versionProvider.getDefaultVersion() } diff --git a/src/server/utils/versionProvider.ts b/src/server/utils/versionProvider.ts index 3581104..9f234f6 100644 --- a/src/server/utils/versionProvider.ts +++ b/src/server/utils/versionProvider.ts @@ -5,7 +5,7 @@ import fs from 'fs' import path from 'path' import { getParentDirs } from './fs' -import { workspace } from 'coc.nvim' +import { workspace, Uri } from 'coc.nvim' import API from './api' import { TypeScriptServiceConfiguration } from './configuration' @@ -101,11 +101,10 @@ export class TypeScriptVersionProvider { return undefined } - public getLocalVersion(root): TypeScriptVersion | undefined { - let paths = getParentDirs(root) - paths.unshift(root) - for (let p of paths) { - if (fs.existsSync(path.join(p, 'node_modules'))) { + public getLocalVersion(): TypeScriptVersion | undefined { + let folders = workspace.workspaceFolders.map(f => Uri.parse(f.uri).fsPath) + for (let p of folders) { + if (fs.existsSync(path.join(p, 'node_modules/typescript/lib'))) { let lib = path.join(p, 'node_modules/typescript/lib') return new TypeScriptVersion(lib) }