From b09548201a723d6cae09722f7dd22b9030e2ba7e Mon Sep 17 00:00:00 2001 From: Brian Ingles Date: Mon, 18 Nov 2024 16:31:00 -0600 Subject: [PATCH] fix: Search filtering now works in PANELS (#177) I fixed a bug where I was setting description instead of label that was breaking built in search / filter in the "PANELS" treeview. Also added search actions to the titlebar of CONNECTIONS + PANELS trees ### Testing ```python from deephaven import empty_table for i in range(100): print(f"Making {i}") globals()[f"t{i}"] = empty_table(10).update(['X = i', 'Y = 10 * i']) ``` - Hover the title of the PANELS tree - Click the search icon (magnifying glass) - Type the name of a variable to filter on - Should scroll to the variable. Clicking the filter button in the search box should actually filter the results resolves #49 --- package.json | 28 ++++++++++++++++ src/common/commands.ts | 2 ++ src/common/constants.ts | 2 ++ src/controllers/ControllerBase.ts | 8 +++-- src/controllers/ExtensionController.ts | 33 +++++++++++++++++-- .../__snapshots__/treeViewUtils.spec.ts.snap | 22 ++++++------- src/util/treeViewUtils.ts | 2 +- 7 files changed, 79 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index 6e85d101..003cda4f 100644 --- a/package.json +++ b/package.json @@ -226,6 +226,16 @@ "command": "vscode-deephaven.createDHEAuthenticatedClient", "title": "Create DHE Authenticated Client" }, + { + "command": "vscode-deephaven.searchConnections", + "title": "Search Connections", + "icon": "$(search)" + }, + { + "command": "vscode-deephaven.searchPanels", + "title": "Search Panels", + "icon": "$(search)" + }, { "command": "vscode-deephaven.startServer", "title": "Deephaven: Start Server", @@ -703,6 +713,14 @@ "command": "vscode-deephaven.refreshVariablePanels", "when": "false" }, + { + "command": "vscode-deephaven.searchConnections", + "when": "false" + }, + { + "command": "vscode-deephaven.searchPanels", + "when": "false" + }, { "command": "vscode-deephaven.createCoreAuthenticatedClient", "when": "false" @@ -746,6 +764,16 @@ "command": "vscode-deephaven.refreshServerConnectionTree", "group": "navigation", "when": "view == vscode-deephaven.serverConnectionTree" + }, + { + "command": "vscode-deephaven.searchConnections", + "group": "navigation", + "when": "view == vscode-deephaven.serverConnectionTree" + }, + { + "command": "vscode-deephaven.searchPanels", + "group": "navigation", + "when": "view == vscode-deephaven.serverConnectionPanelTree" } ], "view/item/context": [ diff --git a/src/common/commands.ts b/src/common/commands.ts index 6a2fac06..4fa13eaf 100644 --- a/src/common/commands.ts +++ b/src/common/commands.ts @@ -31,6 +31,8 @@ export const REFRESH_SERVER_CONNECTION_TREE_CMD = cmd( export const REFRESH_VARIABLE_PANELS_CMD = cmd('refreshVariablePanels'); export const RUN_CODE_COMMAND = cmd('runCode'); export const RUN_SELECTION_COMMAND = cmd('runSelection'); +export const SEARCH_CONNECTIONS_CMD = cmd('searchConnections'); +export const SEARCH_PANELS_CMD = cmd('searchPanels'); export const SELECT_CONNECTION_COMMAND = cmd('selectConnection'); export const START_SERVER_CMD = cmd('startServer'); export const STOP_SERVER_CMD = cmd('stopServer'); diff --git a/src/common/constants.ts b/src/common/constants.ts index 7f670b6c..e0d6ca40 100644 --- a/src/common/constants.ts +++ b/src/common/constants.ts @@ -55,6 +55,8 @@ export const VIEW_ID = { serverConnectionPanelTree: `${EXTENSION_ID}.serverConnectionPanelTree`, } as const; +export type ViewID = (typeof VIEW_ID)[keyof typeof VIEW_ID]; + export const ICON_ID = { blank: 'blank', connected: 'vm-connect', diff --git a/src/controllers/ControllerBase.ts b/src/controllers/ControllerBase.ts index 200b4b1a..2638eaa4 100644 --- a/src/controllers/ControllerBase.ts +++ b/src/controllers/ControllerBase.ts @@ -10,10 +10,12 @@ export abstract class ControllerBase implements Disposable { /** * Register a command and add it's subscription to the disposables list. */ - registerCommand = ( - ...args: Parameters + registerCommand = ( + command: string, + callback: (this: TThis, ...args: any[]) => any, + thisArg?: TThis ): void => { - const cmd = vscode.commands.registerCommand(...args); + const cmd = vscode.commands.registerCommand(command, callback, thisArg); this.disposables.push(cmd); }; diff --git a/src/controllers/ExtensionController.ts b/src/controllers/ExtensionController.ts index fc6cbd96..4ab7f524 100644 --- a/src/controllers/ExtensionController.ts +++ b/src/controllers/ExtensionController.ts @@ -14,10 +14,13 @@ import { REFRESH_SERVER_TREE_CMD, RUN_CODE_COMMAND, RUN_SELECTION_COMMAND, + SEARCH_CONNECTIONS_CMD, + SEARCH_PANELS_CMD, SELECT_CONNECTION_COMMAND, START_SERVER_CMD, STOP_SERVER_CMD, VIEW_ID, + type ViewID, } from '../common'; import { assertDefined, @@ -500,6 +503,20 @@ export class ExtensionController implements Disposable { this.onRefreshServerStatus ); + /** Search connections */ + this.registerCommand( + SEARCH_CONNECTIONS_CMD, + this.onSearchTree, + VIEW_ID.serverConnectionTree + ); + + /** Search variable panels */ + this.registerCommand( + SEARCH_PANELS_CMD, + this.onSearchTree, + VIEW_ID.serverConnectionPanelTree + ); + /** Start a server */ this.registerCommand(START_SERVER_CMD, this.onStartServer); @@ -776,6 +793,14 @@ export class ExtensionController implements Disposable { this.onRunCode(uri, arg, true); }; + /** + * Open search input for tree panel. + */ + onSearchTree = async function (this: ViewID): Promise { + vscode.commands.executeCommand(`${this}.focus`); + vscode.commands.executeCommand('list.find'); + }; + /** * Start a server. */ @@ -794,10 +819,12 @@ export class ExtensionController implements Disposable { /** * Register a command and add it's subscription to the context. */ - registerCommand = ( - ...args: Parameters + registerCommand = ( + command: string, + callback: (this: TThis, ...args: any[]) => any, + thisArg?: TThis ): void => { - const cmd = vscode.commands.registerCommand(...args); + const cmd = vscode.commands.registerCommand(command, callback, thisArg); this._context.subscriptions.push(cmd); }; } diff --git a/src/util/__snapshots__/treeViewUtils.spec.ts.snap b/src/util/__snapshots__/treeViewUtils.spec.ts.snap index eeae18d6..da328bd2 100644 --- a/src/util/__snapshots__/treeViewUtils.spec.ts.snap +++ b/src/util/__snapshots__/treeViewUtils.spec.ts.snap @@ -63,11 +63,11 @@ exports[`getPanelVariableTreeItem > should return panel variable tree item: type "command": "vscode-deephaven.openVariablePanels", "title": "Open Panel", }, - "description": "some title", "iconPath": { "color": undefined, "id": "graph", }, + "label": "some title", } `; @@ -86,11 +86,11 @@ exports[`getPanelVariableTreeItem > should return panel variable tree item: type "command": "vscode-deephaven.openVariablePanels", "title": "Open Panel", }, - "description": "some title", "iconPath": { "color": undefined, "id": "dh-table", }, + "label": "some title", } `; @@ -109,11 +109,11 @@ exports[`getPanelVariableTreeItem > should return panel variable tree item: type "command": "vscode-deephaven.openVariablePanels", "title": "Open Panel", }, - "description": "some title", "iconPath": { "color": undefined, "id": "preview", }, + "label": "some title", } `; @@ -132,11 +132,11 @@ exports[`getPanelVariableTreeItem > should return panel variable tree item: type "command": "vscode-deephaven.openVariablePanels", "title": "Open Panel", }, - "description": "some title", "iconPath": { "color": undefined, "id": "dh-table", }, + "label": "some title", } `; @@ -155,11 +155,11 @@ exports[`getPanelVariableTreeItem > should return panel variable tree item: type "command": "vscode-deephaven.openVariablePanels", "title": "Open Panel", }, - "description": "some title", "iconPath": { "color": undefined, "id": "dh-table", }, + "label": "some title", } `; @@ -178,11 +178,11 @@ exports[`getPanelVariableTreeItem > should return panel variable tree item: type "command": "vscode-deephaven.openVariablePanels", "title": "Open Panel", }, - "description": "some title", "iconPath": { "color": undefined, "id": "dh-table", }, + "label": "some title", } `; @@ -201,11 +201,11 @@ exports[`getPanelVariableTreeItem > should return panel variable tree item: type "command": "vscode-deephaven.openVariablePanels", "title": "Open Panel", }, - "description": "some title", "iconPath": { "color": undefined, "id": "dh-table", }, + "label": "some title", } `; @@ -224,11 +224,11 @@ exports[`getPanelVariableTreeItem > should return panel variable tree item: type "command": "vscode-deephaven.openVariablePanels", "title": "Open Panel", }, - "description": "some title", "iconPath": { "color": undefined, "id": "preview", }, + "label": "some title", } `; @@ -247,11 +247,11 @@ exports[`getPanelVariableTreeItem > should return panel variable tree item: type "command": "vscode-deephaven.openVariablePanels", "title": "Open Panel", }, - "description": "some title", "iconPath": { "color": undefined, "id": "graph", }, + "label": "some title", } `; @@ -270,11 +270,11 @@ exports[`getPanelVariableTreeItem > should return panel variable tree item: type "command": "vscode-deephaven.openVariablePanels", "title": "Open Panel", }, - "description": "some title", "iconPath": { "color": undefined, "id": "preview", }, + "label": "some title", } `; @@ -293,11 +293,11 @@ exports[`getPanelVariableTreeItem > should return panel variable tree item: type "command": "vscode-deephaven.openVariablePanels", "title": "Open Panel", }, - "description": "some title", "iconPath": { "color": undefined, "id": "dh-pandas", }, + "label": "some title", } `; diff --git a/src/util/treeViewUtils.ts b/src/util/treeViewUtils.ts index 5223b793..b841a868 100644 --- a/src/util/treeViewUtils.ts +++ b/src/util/treeViewUtils.ts @@ -80,7 +80,7 @@ export function getPanelVariableTreeItem([url, variable]: [ const iconPath = getVariableIconPath(variable.type); return { - description: variable.title, + label: variable.title, iconPath, command: { title: 'Open Panel',