make useBatchedBufferSync used for update only

Avoid issues with buffer reload by checktime.
This commit is contained in:
chemzqm 2019-09-23 13:12:38 +08:00
parent 30cf468536
commit 91fc042eb2
3 changed files with 7 additions and 25 deletions

View file

@ -74,6 +74,7 @@ this extension.
- `tsserver.implicitProjectConfig.checkJs`:Enable checkJs for implicit project, default: `false`
- `tsserver.implicitProjectConfig.experimentalDecorators`:Enable experimentalDecorators for implicit project, default: `false`
- `tsserver.disableAutomaticTypeAcquisition`:Disable download of typings, default: `false`
- `tsserver.useBatchedBufferSync`: use batched buffer synchronize support.
- `typescript.updateImportsOnFileMove.enable`:Enable update imports on file move., default: `true`
- `typescript.implementationsCodeLens.enable`:Enable codeLens for implementations, default: `true`
- `typescript.referencesCodeLens.enable`:Enable codeLens for references, default: `true`
@ -81,7 +82,6 @@ this extension.
- `typescript.preferences.quoteStyle` default: `"single"`
- `typescript.suggestionActions.enabled`:Enable/disable suggestion diagnostics for TypeScript files in the editor. Requires using TypeScript 2.8 or newer in the workspace., default: `true`
- `typescript.validate.enable`:Enable/disable TypeScript validation., default: `true`
- `typescript.useBatchedBufferSync`: use batched buffer synchronize support.
- `typescript.showUnused`: show unused variable hint, default: `true`.
- `typescript.suggest.enabled` default: `true`
- `typescript.suggest.paths`:Enable/disable suggest paths in import statement and require calls, default: `true`

View file

@ -196,7 +196,7 @@
"default": false,
"description": "Disable download of typings"
},
"typescript.useBatchedBufferSync": {
"tsserver.useBatchedBufferSync": {
"type": "boolean",
"default": true,
"description": "Use batched buffer sync support."

View file

@ -46,30 +46,12 @@ class BufferSynchronizer {
) { }
public open(args: Proto.OpenRequestArgs): void {
if (this.supportsBatching) {
this.updatePending(args.file, pending => {
if (!pending.openFiles) {
pending.openFiles = []
}
pending.openFiles.push(args)
})
} else {
this.client.executeWithoutWaitingForResponse('open', args)
}
this.client.executeWithoutWaitingForResponse('open', args)
}
public close(filepath: string): void {
if (this.supportsBatching) {
this.updatePending(filepath, pending => {
if (!pending.closedFiles) {
pending.closedFiles = []
}
pending.closedFiles.push(filepath)
})
} else {
const args: Proto.FileRequestArgs = { file: filepath }
this.client.executeWithoutWaitingForResponse('close', args)
}
const args: Proto.FileRequestArgs = { file: filepath }
this.client.executeWithoutWaitingForResponse('close', args)
}
public change(filepath: string, events: TextDocumentContentChangeEvent[]): void {
@ -116,7 +98,7 @@ class BufferSynchronizer {
return
}
if (this._pending.changedFiles || this._pending.closedFiles || this._pending.openFiles) {
if (this._pending.changedFiles) {
this.client.executeWithoutWaitingForResponse('updateOpen', this._pending)
this._pending = {}
this._pendingFiles.clear()
@ -124,7 +106,7 @@ class BufferSynchronizer {
}
private get supportsBatching(): boolean {
return this.client.apiVersion.gte(API.v340) && workspace.getConfiguration('typescript').get<boolean>('useBatchedBufferSync', true)
return this.client.apiVersion.gte(API.v340) && workspace.getConfiguration('tsserver').get<boolean>('useBatchedBufferSync', true)
}
private updatePending(filepath: string, f: (pending: Proto.UpdateOpenRequestArgs) => void): void {