Fix kernel name check bug, double-event hooking, and other Notebook issues (#4016)

* Fix error where kernel name was compared to itself. This doesn't break anything right now since we happen to have special handling of Python3, and for other kernels they share the same set of supported providers (which is what the check is used for). However it needs fixing for next release.
* Fix console error due to queryTextEditor trying to access model before it's ready
* Fix issues where notebook model hooked to session events multiple times
* Removed calls that weren't needed such as loadActiveContexts (if undefined, does nothing) and passing connection to initialize method
This commit is contained in:
Kevin Cunnane
2019-02-12 14:26:22 -08:00
committed by GitHub
parent 7ef2d52efd
commit 0aa71b5237
4 changed files with 17 additions and 16 deletions

View File

@@ -391,15 +391,14 @@ export class NotebookModel extends Disposable implements INotebookModel {
this._activeConnection = undefined;
}
clientSession.initialize(this._activeConnection);
clientSession.initialize();
this._sessionLoadFinished = clientSession.ready.then(async () => {
if (clientSession.isInErrorState) {
this.setErrorState(clientSession.errorMessage);
} else {
this._onClientSessionReady.fire(clientSession);
// Once session is loaded, can use the session manager to retrieve useful info
this.loadKernelInfo();
await this.loadActiveContexts(undefined);
this.loadKernelInfo(clientSession);
}
});
});
@@ -488,11 +487,12 @@ export class NotebookModel extends Disposable implements INotebookModel {
}
}
private loadKernelInfo(): void {
this._clientSessions.forEach(clientSession => {
clientSession.onKernelChanging(async (e) => {
await this.loadActiveContexts(e);
});
private loadKernelInfo(clientSession: IClientSession): void {
clientSession.onKernelChanging(async (e) => {
await this.loadActiveContexts(e);
});
clientSession.statusChanged(async (session) => {
this._kernelsChangedEmitter.fire(session.kernel);
});
if (!this.notebookManager) {
return;
@@ -503,11 +503,6 @@ export class NotebookModel extends Disposable implements INotebookModel {
if (!this._defaultKernel) {
this._defaultKernel = NotebookContexts.getDefaultKernel(sessionManager.specs, this.connectionProfile, this._savedKernelInfo);
}
this._clientSessions.forEach(clientSession => {
clientSession.statusChanged(async (session) => {
this._kernelsChangedEmitter.fire(session.kernel);
});
});
let spec = this.getKernelSpecFromDisplayName(this._defaultKernel.display_name);
if (spec) {
this._defaultKernel = spec;
@@ -551,7 +546,7 @@ export class NotebookModel extends Disposable implements INotebookModel {
if (!specs || !specs.kernels) {
return kernel.name;
}
let newKernel = this.notebookManager.sessionManager.specs.kernels.find(kernel => kernel.name === kernel.name);
let newKernel = this.notebookManager.sessionManager.specs.kernels.find(k => k.name === kernel.name);
let newKernelDisplayName;
if (newKernel) {
newKernelDisplayName = newKernel.display_name;