resolve local tsserver from workspaceFolders
This commit is contained in:
parent
f29a6f424b
commit
fe5c4d84dd
2 changed files with 6 additions and 7 deletions
|
@ -242,7 +242,7 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
|
|||
}
|
||||
|
||||
private async startService(resendModels = false): Promise<ForkedTsServerProcess> {
|
||||
let currentVersion = this.versionProvider.getLocalVersion(workspace.root)
|
||||
let currentVersion = this.versionProvider.getLocalVersion()
|
||||
if (!currentVersion || !fs.existsSync(currentVersion.tsServerPath)) {
|
||||
currentVersion = await this.versionProvider.getDefaultVersion()
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue