From a31d8acf666570923627c1bec9044f4120d3ff49 Mon Sep 17 00:00:00 2001 From: Qiming Zhao Date: Wed, 9 Dec 2020 15:21:17 +0800 Subject: [PATCH] fix validate settings not respected Closes #238 --- src/server/features/bufferSyncSupport.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/server/features/bufferSyncSupport.ts b/src/server/features/bufferSyncSupport.ts index fdfa8ae..88020a1 100644 --- a/src/server/features/bufferSyncSupport.ts +++ b/src/server/features/bufferSyncSupport.ts @@ -480,7 +480,10 @@ export default class BufferSyncSupport { } public getErr(resources: Uri[]): any { - const handledResources = resources.filter(resource => this.handles(resource.toString())) + const handledResources = resources.filter(resource => { + let syncedBuffer = this.syncedBuffers.get(resource.toString()) + return syncedBuffer && this.shouldValidate(syncedBuffer) + }) if (!handledResources.length) { return } @@ -525,15 +528,20 @@ export default class BufferSyncSupport { this.pendingGetErr.cancel() for (const uri of this.pendingGetErr.uris) { let resource = uri.toString() - if (this.syncedBuffers.get(resource)) { + let syncedBuffer = this.syncedBuffers.get(resource) + if (syncedBuffer && this.shouldValidate(syncedBuffer)) { orderedFileSet.set(resource, undefined) + } else { + orderedFileSet.delete(resource) } } this.pendingGetErr = undefined } // Add all open TS buffers to the geterr request. They might be visible for (const buffer of this.syncedBuffers.values) { - orderedFileSet.set(buffer.resource, undefined) + if (this.shouldValidate(buffer)) { + orderedFileSet.set(buffer.resource, undefined) + } } if (orderedFileSet.size) { let uris = Array.from(orderedFileSet.uris).map(uri => Uri.parse(uri)) @@ -554,7 +562,7 @@ export default class BufferSyncSupport { this._validateTypeScript = tsConfig.get('validate.enable', true) } - private shouldValidate(buffer: SyncedBuffer) { + private shouldValidate(buffer: SyncedBuffer): boolean { switch (buffer.kind) { case BufferKind.JavaScript: return this._validateJavaScript