From 8a7bbd1795a5a0ec91893146d4f2a68e6f6ab2df Mon Sep 17 00:00:00 2001 From: David Shiflet Date: Wed, 30 Jan 2019 18:18:25 -0500 Subject: [PATCH] Pass connectionid to registered commands from command line (#3861) * pass connectionid to registered commands from commandline * remove blank lines * fix commandline unit test --- extensions/notebook/src/extension.ts | 12 ++++++++++-- .../commandLine/common/commandLineService.ts | 2 +- .../parts/commandLine/commandLineService.test.ts | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/extensions/notebook/src/extension.ts b/extensions/notebook/src/extension.ts index 7ff0c3e292..28fb07d7b3 100644 --- a/extensions/notebook/src/extension.ts +++ b/extensions/notebook/src/extension.ts @@ -13,10 +13,18 @@ const localize = nls.loadMessageBundle(); let counter = 0; export function activate(extensionContext: vscode.ExtensionContext) { - extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.new', () => { + extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.new', ( connectionId? : string) => { let title = `Untitled-${counter++}`; let untitledUri = vscode.Uri.parse(`untitled:${title}`); - sqlops.nb.showNotebookDocument(untitledUri).then(success => { + let options: sqlops.nb.NotebookShowOptions = connectionId? { + viewColumn : null, + preserveFocus : true, + preview: null, + providerId : null, + connectionId : connectionId, + defaultKernel : null + } : null; + sqlops.nb.showNotebookDocument(untitledUri, options).then(success => { }, (err: Error) => { vscode.window.showErrorMessage(err.message); diff --git a/src/sql/workbench/services/commandLine/common/commandLineService.ts b/src/sql/workbench/services/commandLine/common/commandLineService.ts index 285a624223..06dbcb0720 100644 --- a/src/sql/workbench/services/commandLine/common/commandLineService.ts +++ b/src/sql/workbench/services/commandLine/common/commandLineService.ts @@ -111,7 +111,7 @@ export class CommandLineService implements ICommandLineProcessing { } else { self._connectionManagementService.connectIfNotConnected(self._connectionProfile, 'connection', true) .then(() => { - self._commandService.executeCommand(self._commandName, self._connectionProfile).then(() => resolve(), error => reject(error)); + self._commandService.executeCommand(self._commandName, self._connectionProfile.id).then(() => resolve(), error => reject(error)); }, error => { reject(error); }); diff --git a/src/sqltest/parts/commandLine/commandLineService.test.ts b/src/sqltest/parts/commandLine/commandLineService.test.ts index 7372a12b75..77a2bde1fa 100644 --- a/src/sqltest/parts/commandLine/commandLineService.test.ts +++ b/src/sqltest/parts/commandLine/commandLineService.test.ts @@ -246,7 +246,7 @@ suite('commandLineService tests', () => { connectionManagementService.setup(c => c.connectIfNotConnected(TypeMoq.It.is(p => p.serverName === 'myserver'), 'connection', true)) .returns(() => new Promise((resolve, reject) => { resolve('unused'); })) .verifiable(TypeMoq.Times.once()); - commandService.setup(c => c.executeCommand('mycommand', TypeMoq.It.is(p => p.serverName === 'myserver'))) + commandService.setup(c => c.executeCommand('mycommand', TypeMoq.It.isAnyString())) .returns(() => TPromise.wrap(1)) .verifiable(TypeMoq.Times.once()); const configurationService = getConfigurationServiceMock(true);