Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions packages/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@
"command": "sqltools.copyTextFromTreeItem",
"category": "SQLTools Sidebar"
},
{
"title": "Copy Selected Message(s)",
"command": "sqltools.copyTextFromConsoleMessages"
},
{
"title": "Generate Insert Query",
"command": "sqltools.generateInsertQuery",
Expand Down Expand Up @@ -1034,6 +1038,10 @@
"command": "sqltools.copyTextFromTreeItem",
"when": "false"
},
{
"command": "sqltools.copyTextFromConsoleMessages",
"when": "false"
},
{
"command": "sqltools.refreshTree",
"when": "false"
Expand Down Expand Up @@ -1160,9 +1168,9 @@
"group": "sqltools.connectionExplorer.edit@1"
},
{
"command": "sqltools.copyTextFromTreeItem",
"command": "sqltools.copyTextFromConsoleMessages",
"when": "view == sqltoolsViewConsoleMessages",
"group": "sqltools.connectionExplorer.edit@1"
"group": "sqltools.consoleMessages.edit@1"
},
{
"command": "sqltools.selectConnection",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/connection-manager/explorer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class ConnectionExplorer implements TreeDataProvider<SidebarTreeItem>, Tr
}
});
this.messagesTreeViewProvider = new MessagesProvider();
this.messagesTreeView = window.createTreeView(`${EXT_NAMESPACE}ViewConsoleMessages`, { treeDataProvider: this.messagesTreeViewProvider, canSelectMany: false, showCollapseAll: true });
this.messagesTreeView = window.createTreeView(`${EXT_NAMESPACE}ViewConsoleMessages`, { treeDataProvider: this.messagesTreeViewProvider, canSelectMany: true, showCollapseAll: true });
Context.subscriptions.push(this.treeView, this.messagesTreeView);
}

Expand Down
5 changes: 5 additions & 0 deletions packages/plugins/connection-manager/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,10 @@ export class ConnectionManagerPlugin implements IExtensionPlugin {
this.updateAttachedConnectionsMap(fileUri);
}

private ext_copyTextFromConsoleMessages = async (item, selectedNodes) => {
return commands.executeCommand(`${EXT_NAMESPACE}.copyMessages`, item, selectedNodes);
}

private ext_copyTextFromTreeItem = async () => {
const nodes = this.explorer.getSelection();
if (!nodes || nodes.length === 0) return;
Expand Down Expand Up @@ -792,6 +796,7 @@ export class ConnectionManagerPlugin implements IExtensionPlugin {
.registerCommand(`testConnection`, this.ext_testConnection)
.registerCommand(`getConnections`, this.ext_getConnections)
.registerCommand(`detachConnectionFromFile`, this.ext_detachConnectionFromFile)
.registerCommand(`copyTextFromConsoleMessages`, this.ext_copyTextFromConsoleMessages)
.registerCommand(`copyTextFromTreeItem`, this.ext_copyTextFromTreeItem)
.registerCommand(`getChildrenForTreeItem`, this.ext_getChildrenForTreeItem)
.registerCommand(`getInsertQuery`, this.ext_getInsertQuery);
Expand Down
8 changes: 8 additions & 0 deletions packages/plugins/formatter/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ function copyTextHandler(item: { value: string } | string, items?: ({ value: str
return env.clipboard.writeText(copyText);
}

function copyMessagesHandler(item: { value: string } | string, items?: ({ value: string } | string)[]) {
items = items ? items : [item];
const copyText = items.filter(n => n !== null && typeof n !== 'undefined').map(item => `${(<any>item).label || item} [${(<any>item).description}]`).join('\n');
if (!copyText) return;
return env.clipboard.writeText(copyText);
}

async function generateInsertQueryHandler(item: SidebarItem) {
const columns: NSDatabase.IColumn[] = await commands.executeCommand(`${EXT_NAMESPACE}.getChildrenForTreeItem`, {
conn: item.conn,
Expand All @@ -76,6 +83,7 @@ const register = (extension: IExtension) => {
extension.registerTextEditorCommand(`formatSql`, formatSqlHandler)
.registerCommand(`insertText`, insertTextHandler)
.registerCommand(`copyText`, copyTextHandler)
.registerCommand(`copyMessages`, copyMessagesHandler)
.registerCommand(`generateInsertQuery`, generateInsertQueryHandler)
.registerCommand(`newSqlFile`, newSqlFileHandler);
}
Expand Down