fix configured tsserver.tsdk not used

Use configured tsserver.tsdk when local tsserver not used.
This commit is contained in:
Qiming Zhao 2022-08-29 18:21:23 +08:00
parent 35a9f25423
commit 63e22e092c
No known key found for this signature in database
GPG key ID: 9722CD0E8D4DCB8C
2 changed files with 15 additions and 2 deletions

View file

@ -227,7 +227,16 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
if (this.tscPathVim) currentVersion = this.versionProvider.getVersionFromTscPath(this.tscPathVim)
if (!currentVersion && !ignoreLocalTsserver) currentVersion = this.versionProvider.getLocalVersion()
if (!currentVersion || !fs.existsSync(currentVersion.tsServerPath)) {
this.info('Local tsserver not found, using bundled tsserver with coc-tsserver.')
if (ignoreLocalTsserver) {
this.info(`local tsserver is ignored, try global version`)
} else {
this.info(`local tsserver is not found, try global version`)
}
currentVersion = this.versionProvider.globalVersion
if (currentVersion) this.info('Local and global tsserver not found, using global tsserver from configuration')
}
if (!currentVersion || !fs.existsSync(currentVersion.tsServerPath)) {
this.info('Local and global tsserver not found, using bundled tsserver with coc-tsserver.')
currentVersion = this.versionProvider.getDefaultVersion()
}
if (!currentVersion || !currentVersion.isValid) {

View file

@ -102,7 +102,11 @@ export class TypeScriptVersionProvider {
public get globalVersion(): TypeScriptVersion | undefined {
let { globalTsdk } = this.configuration
if (globalTsdk) return new TypeScriptVersion(workspace.expand(globalTsdk))
let folder = workspace.expand(globalTsdk)
if (!path.isAbsolute(folder)) {
folder = path.join(workspace.root, folder)
}
if (globalTsdk) return new TypeScriptVersion(folder)
return undefined
}