fix(tsserver): fix project root path resolve
This commit is contained in:
parent
d1d341b2a8
commit
931a0046d9
3 changed files with 5 additions and 6 deletions
|
@ -101,7 +101,7 @@ export default class BufferSyncSupport {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.client.apiVersion.gte(API.v230)) {
|
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
|
this.client.execute('open', args, false) // tslint:disable-line
|
||||||
|
|
|
@ -39,7 +39,7 @@ export interface ITypeScriptServiceClient {
|
||||||
onTypesInstallerInitializationFailed: Event<Proto.TypesInstallerInitializationFailedEventBody>
|
onTypesInstallerInitializationFailed: Event<Proto.TypesInstallerInitializationFailedEventBody>
|
||||||
readonly logger: Logger
|
readonly logger: Logger
|
||||||
|
|
||||||
getWorkspaceRootForResource(uri: string): string
|
getProjectRootPath(uri: string): string
|
||||||
normalizePath(resource: Uri): string | null
|
normalizePath(resource: Uri): string | null
|
||||||
asUrl(filepath: string): Uri
|
asUrl(filepath: string): Uri
|
||||||
toPath(uri: string): string
|
toPath(uri: string): string
|
||||||
|
|
|
@ -318,7 +318,6 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
|
||||||
workspace.showMessage(`Can not find tsserver, run ':CocInstall coc-tsserver' to fix it!`, 'error')
|
workspace.showMessage(`Can not find tsserver, run ':CocInstall coc-tsserver' to fix it!`, 'error')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
workspace.showMessage(`Using tsserver from: ${currentVersion.path}`) // tslint:disable-line
|
|
||||||
this._apiVersion = currentVersion.version
|
this._apiVersion = currentVersion.version
|
||||||
this.versionStatus.onDidChangeTypeScriptVersion(currentVersion)
|
this.versionStatus.onDidChangeTypeScriptVersion(currentVersion)
|
||||||
this.requestQueue = new RequestQueue()
|
this.requestQueue = new RequestQueue()
|
||||||
|
@ -813,11 +812,11 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
|
||||||
return args
|
return args
|
||||||
}
|
}
|
||||||
|
|
||||||
public getWorkspaceRootForResource(uri: string): string {
|
public getProjectRootPath(uri: string): string {
|
||||||
let u = Uri.parse(uri)
|
let u = Uri.parse(uri)
|
||||||
if (u.scheme != 'file') return workspace.root
|
if (u.scheme != 'file') return workspace.root
|
||||||
let res = findUp.sync(['package.json', '.vim', '.git', '.hg'], { cwd: path.dirname(u.fsPath) })
|
let res = findUp.sync(['tsconfig.json', 'jsconfig.json', 'package.json'], { cwd: path.dirname(u.fsPath) })
|
||||||
return res ? path.dirname(res) : null
|
return res ? path.dirname(res) : workspace.rootPath
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue