mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-06 09:35:41 -05:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user