From 5810623e558664b0b469372ee98a113e6348a498 Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Fri, 15 Jan 2021 12:54:29 -0800 Subject: [PATCH] Don't capture query history events until service is started (#13983) --- .../queryHistory/common/queryHistoryServiceImpl.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/sql/workbench/services/queryHistory/common/queryHistoryServiceImpl.ts b/src/sql/workbench/services/queryHistory/common/queryHistoryServiceImpl.ts index 86aa0a0df9..ca2c97b422 100644 --- a/src/sql/workbench/services/queryHistory/common/queryHistoryServiceImpl.ts +++ b/src/sql/workbench/services/queryHistory/common/queryHistoryServiceImpl.ts @@ -26,6 +26,8 @@ export class QueryHistoryService extends Disposable implements IQueryHistoryServ private _onInfosUpdated: Emitter = new Emitter(); private _onQueryHistoryCaptureChanged: Emitter = new Emitter(); private _captureEnabled: boolean; + private _started: boolean = false; + // EVENTS ////////////////////////////////////////////////////////////// public get onInfosUpdated(): Event { return this._onInfosUpdated.event; } public get onQueryHistoryCaptureChanged(): Event { return this._onQueryHistoryCaptureChanged.event; } @@ -38,7 +40,7 @@ export class QueryHistoryService extends Disposable implements IQueryHistoryServ ) { super(); - this._captureEnabled = !!this._configurationService.getValue('queryHistory.captureEnabled'); + this.updateCaptureEnabled(); this._register(this._configurationService.onDidChangeConfiguration((e: IConfigurationChangeEvent) => { if (e.affectedKeys.find(x => x === 'queryHistory.captureEnabled')) { @@ -117,7 +119,7 @@ export class QueryHistoryService extends Disposable implements IQueryHistoryServ private updateCaptureEnabled(): void { const currentCaptureEnabled = this._captureEnabled; - this._captureEnabled = !!this._configurationService.getValue('queryHistory.captureEnabled'); + this._captureEnabled = !!this._configurationService.getValue('queryHistory.captureEnabled') && this._started; if (currentCaptureEnabled !== this._captureEnabled) { this._onQueryHistoryCaptureChanged.fire(this._captureEnabled); } @@ -127,6 +129,7 @@ export class QueryHistoryService extends Disposable implements IQueryHistoryServ * Method to force initialization of the service so that it can start tracking query events */ public start(): void { - + this._started = true; + this.updateCaptureEnabled(); } }