Skip to content

Commit

Permalink
Delay showing SQL CONSOLE tab in Panel until first query is run
Browse files Browse the repository at this point in the history
  • Loading branch information
gjsjohnmurray committed May 1, 2024
1 parent 2d9f934 commit 9605f3f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,8 @@
"sqltoolsPanelContainer": [
{
"id": "sqltoolsViewConsoleMessages",
"name": "Messages"
"name": "Messages",
"when": "sqltools.consoleMessages.active"
}
]
},
Expand Down
5 changes: 5 additions & 0 deletions packages/plugins/connection-manager/explorer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ export class ConnectionExplorer implements TreeDataProvider<SidebarTreeItem>, Tr

export class MessagesProvider implements TreeDataProvider<TreeItem> {
private items: TreeItem[] = [];
private active: boolean = false;
private _onDidChangeTreeData: EventEmitter<TreeItem> = new EventEmitter();
public readonly onDidChangeTreeData = this._onDidChangeTreeData.event;
getTreeItem(element: TreeItem): TreeItem | Thenable<TreeItem> {
Expand All @@ -249,6 +250,10 @@ export class MessagesProvider implements TreeDataProvider<TreeItem> {
}

addMessages = (messages: NSDatabase.IResult['messages'] = []) => {
if (!this.active && messages.length > 0) {
this.active = true;
commands.executeCommand('setContext', `${EXT_NAMESPACE}.consoleMessages.active`, true);
}
this.items = messages.map(m => {
let item: TreeItem;
if (typeof m === 'string') {
Expand Down

0 comments on commit 9605f3f

Please sign in to comment.