in src/controllers/mainController.ts [447:524]
private initializeQueryHistory(): void {
let config = this._vscodeWrapper.getConfiguration(Constants.extensionConfigSectionName);
let queryHistoryFeature = config.get(Constants.configEnableQueryHistoryFeature);
// If the query history feature is enabled
if (queryHistoryFeature && !this._queryHistoryRegistered) {
// Register the query history tree provider
this._queryHistoryProvider = new QueryHistoryProvider(this._connectionMgr, this._outputContentProvider,
this._vscodeWrapper, this._untitledSqlDocumentService, this._statusview, this._prompter);
this._context.subscriptions.push(
vscode.window.registerTreeDataProvider('queryHistory', this._queryHistoryProvider)
);
// Command to refresh Query History
this._context.subscriptions.push(
vscode.commands.registerCommand(
Constants.cmdRefreshQueryHistory, (ownerUri: string, hasError: boolean) => {
config = this._vscodeWrapper.getConfiguration(Constants.extensionConfigSectionName);
let queryHistoryFeatureEnabled = config.get(Constants.configEnableQueryHistoryFeature);
let queryHistoryCaptureEnabled = config.get(Constants.configEnableQueryHistoryCapture);
if (queryHistoryFeatureEnabled && queryHistoryCaptureEnabled) {
const timeStamp = new Date();
this._queryHistoryProvider.refresh(ownerUri, timeStamp, hasError);
}
}));
// Command to enable clear all entries in Query History
this._context.subscriptions.push(
vscode.commands.registerCommand(
Constants.cmdClearAllQueryHistory, () => {
this._queryHistoryProvider.clearAll();
}));
// Command to enable delete an entry in Query History
this._context.subscriptions.push(
vscode.commands.registerCommand(
Constants.cmdDeleteQueryHistory, (node: QueryHistoryNode) => {
this._queryHistoryProvider.deleteQueryHistoryEntry(node);
}));
// Command to enable open a query in Query History
this._context.subscriptions.push(
vscode.commands.registerCommand(
Constants.cmdOpenQueryHistory, async (node: QueryHistoryNode) => {
await this._queryHistoryProvider.openQueryHistoryEntry(node);
}));
// Command to enable run a query in Query History
this._context.subscriptions.push(
vscode.commands.registerCommand(
Constants.cmdRunQueryHistory, async (node: QueryHistoryNode) => {
await this._queryHistoryProvider.openQueryHistoryEntry(node, true);
}));
// Command to start the query history capture
this._context.subscriptions.push(
vscode.commands.registerCommand(
Constants.cmdStartQueryHistory, async (node: QueryHistoryNode) => {
await this._queryHistoryProvider.startQueryHistoryCapture();
}));
// Command to pause the query history capture
this._context.subscriptions.push(
vscode.commands.registerCommand(
Constants.cmdPauseQueryHistory, async (node: QueryHistoryNode) => {
await this._queryHistoryProvider.pauseQueryHistoryCapture();
}));
// Command to open the query history experience in the command palette
this._context.subscriptions.push(
vscode.commands.registerCommand(
Constants.cmdCommandPaletteQueryHistory, async () => {
await this._queryHistoryProvider.showQueryHistoryCommandPalette();
}));
this._queryHistoryRegistered = true;
}
}