Update Query History README (#20716)

* Add max entries to query history

* Update query history README
This commit is contained in:
Charles Gagnon
2022-10-03 16:19:02 -07:00
committed by GitHub
parent dd0e8fed2e
commit 266326252a
5 changed files with 22 additions and 6 deletions

View File

@@ -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.

View File

@@ -98,6 +98,11 @@
"title": "%queryHistory.enableCapture%",
"category": "%queryHistory.displayName%",
"icon": "$(play)"
},
{
"command": "queryHistory.openStorageFolder",
"title": "%queryHistory.openStorageFolder%",
"category": "%queryHistory.displayName%"
}
],
"menus": {

View File

@@ -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"
}

View File

@@ -21,14 +21,15 @@ const DOUBLE_CLICK_TIMEOUT_MS = 500;
export async function activate(context: vscode.ExtensionContext): Promise<void> {
// 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<void>
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<void> {

View File

@@ -45,8 +45,8 @@ export class QueryHistoryProvider implements vscode.TreeDataProvider<QueryHistor
*/
private queryTextMappings: Map<string, string> = new Map<string, string>();
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 => {