Fixed #4800 need to use ConnectionProfile in order to get the correct… (#4812)

* Fixed #4800 need to use ConnectionProfile in order to get the correct connection

* Go back to create connect in run cell to avoid to fail to run cell or close the connection used by other.
This commit is contained in:
Yurong He
2019-04-03 19:00:56 -07:00
committed by GitHub
parent a34692b6f2
commit 504d5c91bc
3 changed files with 14 additions and 10 deletions

View File

@@ -637,19 +637,19 @@ export class NotebookModel extends Disposable implements INotebookModel {
return spec;
}
public async changeContext(server: string, newConnection?: ConnectionProfile, hideErrorMessage?: boolean): Promise<void> {
public async changeContext(title: string, newConnection?: ConnectionProfile, hideErrorMessage?: boolean): Promise<void> {
try {
if (!newConnection) {
newConnection = this._activeContexts.otherConnections.find((connection) => connection.serverName === server);
newConnection = this._activeContexts.otherConnections.find((connection) => connection.title === title);
}
if ((!newConnection) && (this._activeContexts.defaultConnection.serverName === server)) {
if ((!newConnection) && (this._activeContexts.defaultConnection.title === title)) {
newConnection = this._activeContexts.defaultConnection;
}
if (this._activeConnection) {
this._otherConnections.push(this._activeConnection);
}
if (newConnection) {
if (this._activeConnection && this._activeConnection.id !== newConnection.id) {
this._otherConnections.push(this._activeConnection);
}
this._activeConnection = newConnection;
this.refreshConnections(newConnection);
this._activeClientSession.updateConnection(newConnection.toIConnectionProfile()).then(