File tree Expand file tree Collapse file tree 3 files changed +32
-2
lines changed
extensions/ql-vscode/src/databases/ui Expand file tree Collapse file tree 3 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -254,6 +254,11 @@ export class DbPanel extends DisposableObject {
254254 "Not a selectable database item. Please select a valid item." ,
255255 ) ;
256256 }
257+
258+ // Optimistically update the UI to select the item that the user
259+ // selected to avoid delay in the UI.
260+ this . dataProvider . updateSelectedItem ( treeViewItem ) ;
261+
257262 await this . dbManager . setSelectedDbItem ( treeViewItem . dbItem ) ;
258263 }
259264
Original file line number Diff line number Diff line change @@ -48,6 +48,23 @@ export class DbTreeDataProvider
4848 } ) ;
4949 }
5050
51+ /**
52+ * Updates the selected item and re-renders the tree.
53+ * @param selectedItem The item to select.
54+ */
55+ public updateSelectedItem ( selectedItem : DbTreeViewItem ) : void {
56+ // Unselect all items
57+ for ( const item of this . dbTreeItems ) {
58+ item . setAsUnselected ( ) ;
59+ }
60+
61+ // Select the new item
62+ selectedItem . setAsSelected ( ) ;
63+
64+ // Re-render the tree
65+ this . _onDidChangeTreeData . fire ( undefined ) ;
66+ }
67+
5168 /**
5269 * Called when expanding a node (including the root node).
5370 * @param node The node to expand.
Original file line number Diff line number Diff line change @@ -36,11 +36,19 @@ export class DbTreeViewItem extends vscode.TreeItem {
3636 if ( dbItem ) {
3737 this . contextValue = getContextValue ( dbItem ) ;
3838 if ( isSelectableDbItem ( dbItem ) && dbItem . selected ) {
39- // Define the resource id to drive the UI to render this item as selected.
40- this . resourceUri = vscode . Uri . parse ( SELECTED_DB_ITEM_RESOURCE_URI ) ;
39+ this . setAsSelected ( ) ;
4140 }
4241 }
4342 }
43+
44+ public setAsSelected ( ) : void {
45+ // Define the resource id to drive the UI to render this item as selected.
46+ this . resourceUri = vscode . Uri . parse ( SELECTED_DB_ITEM_RESOURCE_URI ) ;
47+ }
48+
49+ public setAsUnselected ( ) : void {
50+ this . resourceUri = undefined ;
51+ }
4452}
4553
4654function getContextValue ( dbItem : DbItem ) : string | undefined {
You can’t perform that action at this time.
0 commit comments