Skip to content

Commit 9ca1ba0

Browse files
committed
create execution script for blitzindex against correct connection from object explorer
1 parent c4db641 commit 9ca1ba0

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ export function activate(context: vscode.ExtensionContext) {
183183
scriptText += `
184184
-- for more info: https://www.brentozar.com/blitzindex/
185185
`;
186-
new placeScript().placescript(fileName,scriptText);
186+
new placeScript().placescript(fileName,scriptText,context);
187187

188188
};
189189
var disposable_runspblitzindex = vscode.commands.registerCommand('extension.run_sp_blitzindex', runspblitzindex);

src/placescript.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,24 @@ import * as vscode from 'vscode';
55

66
export class placeScript {
77
// places scriptText into fileName editor with current connection
8-
public async placescript(fileName, scriptText) {
8+
public async placescript(fileName, scriptText, context?: sqlops.ObjectExplorerContext) {
99
var setting: vscode.Uri = vscode.Uri.parse("untitled:" + fileName);
1010
try {
11-
let connection = await sqlops.connection.getCurrentConnection();
11+
var connectId;
12+
if (context) {
13+
let connection = context.connectionProfile;
14+
connectId = connection.id;
15+
} else {
16+
let connection = await sqlops.connection.getCurrentConnection();
17+
connectId = connection.connectionId;
18+
}
1219
let doc = await vscode.workspace.openTextDocument(setting);
1320
let editor = await vscode.window.showTextDocument(doc, 1, false);
1421
editor.edit(edit => {
1522
edit.insert(new vscode.Position(0, 0), scriptText);
1623
});
17-
if (connection) {
18-
await sqlops.queryeditor.connect(doc.uri.toString(), connection.connectionId);
24+
if (connectId) {
25+
await sqlops.queryeditor.connect(doc.uri.toString(), connectId);
1926
}
2027
} catch (err) {
2128
vscode.window.showErrorMessage(err);

0 commit comments

Comments
 (0)