diff --git a/extensions/query-history/README.md b/extensions/query-history/README.md index 950806d5c2..e86296e0e8 100644 --- a/extensions/query-history/README.md +++ b/extensions/query-history/README.md @@ -50,9 +50,15 @@ This will permanently delete **ALL** history rows. This action is also available from the command palette (**Query History: Clear All History**) and as an action button on the panel. +### Configuration + +Configuration settings can be found in the `Query History` section. See the `Feature Contributions` tab for details on all the avilable settings. + ### Data Storage -Currently all information is stored in-memory and not persisted upon application exit. There is no limit to the number of entries stored, new entries will be continuously added as long as capture is enabled unless entries are deleted or the entire history is cleared. +If persistence is not enabled then all information is stored in-memory and not persisted upon application exit. If persistence is enabled then information is written to disk in an encrypted file which can be located by running the `Query History: Open storage folder` command. + + The number of entries stored is controlled by the `queryHistory.maxEntries` configuration, once that many entries have been stored then any new entries will cause the oldest item to be removed. ## Code of Conduct This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. diff --git a/extensions/query-history/package.json b/extensions/query-history/package.json index bd84c7ffb4..a45ca427cd 100644 --- a/extensions/query-history/package.json +++ b/extensions/query-history/package.json @@ -98,6 +98,11 @@ "title": "%queryHistory.enableCapture%", "category": "%queryHistory.displayName%", "icon": "$(play)" + }, + { + "command": "queryHistory.openStorageFolder", + "title": "%queryHistory.openStorageFolder%", + "category": "%queryHistory.displayName%" } ], "menus": { diff --git a/extensions/query-history/package.nls.json b/extensions/query-history/package.nls.json index 89bf246fff..3e46da8fbe 100644 --- a/extensions/query-history/package.nls.json +++ b/extensions/query-history/package.nls.json @@ -13,5 +13,6 @@ "queryHistory.disableCapture": "Pause Query History Capture", "queryHistory.enableCapture": "Start Query History Capture", "queryHistory.noEntries": "No queries to display", - "queryHistory.maxEntries": "Maximum number of entries to store. 0 means unlimited entries are stored. Increasing this limit may impact performance, especially if persistence is enabled." + "queryHistory.maxEntries": "Maximum number of entries to store. 0 means unlimited entries are stored. Increasing this limit may impact performance, especially if persistence is enabled.", + "queryHistory.openStorageFolder": "Open storage folder" } diff --git a/extensions/query-history/src/main.ts b/extensions/query-history/src/main.ts index e6174888cd..40a03abe6a 100644 --- a/extensions/query-history/src/main.ts +++ b/extensions/query-history/src/main.ts @@ -21,14 +21,15 @@ const DOUBLE_CLICK_TIMEOUT_MS = 500; export async function activate(context: vscode.ExtensionContext): Promise { // Create the global storage folder now for storing the query history persistance file + const storageUri = context.globalStorageUri; try { - await fs.mkdir(context.globalStorageUri.fsPath); + await fs.mkdir(storageUri.fsPath); } catch (err) { if (err.code !== 'EEXIST') { console.error(`Error creating query history global storage folder ${context.globalStorageUri.fsPath}. ${err}`); } } - const treeDataProvider = new QueryHistoryProvider(context); + const treeDataProvider = new QueryHistoryProvider(context, storageUri); context.subscriptions.push(treeDataProvider); const treeView = vscode.window.createTreeView('queryHistory', { treeDataProvider, @@ -83,6 +84,9 @@ export async function activate(context: vscode.ExtensionContext): Promise context.subscriptions.push(vscode.commands.registerCommand('queryHistory.enableCapture', async () => { return treeDataProvider.setCaptureEnabled(true); })); + context.subscriptions.push(vscode.commands.registerCommand('queryHistory.openStorageFolder', async () => { + return vscode.env.openExternal(storageUri); + })); } async function openQuery(item: QueryHistoryItem): Promise { diff --git a/extensions/query-history/src/queryHistoryProvider.ts b/extensions/query-history/src/queryHistoryProvider.ts index 73fa59fdc2..285cd1d1de 100644 --- a/extensions/query-history/src/queryHistoryProvider.ts +++ b/extensions/query-history/src/queryHistoryProvider.ts @@ -45,8 +45,8 @@ export class QueryHistoryProvider implements vscode.TreeDataProvider = new Map(); - constructor(private _context: vscode.ExtensionContext) { - this._historyStorageFile = path.join(this._context.globalStorageUri.fsPath, HISTORY_STORAGE_FILE_NAME); + constructor(private _context: vscode.ExtensionContext, storageUri: vscode.Uri) { + this._historyStorageFile = path.join(storageUri.fsPath, HISTORY_STORAGE_FILE_NAME); // Kick off initialization but then continue on since that may take a while and we don't want to block extension activation void this.initialize(); this._disposables.push(vscode.workspace.onDidChangeConfiguration(async e => {