From 7e3d5a0ce0f66bbdb959574fa47565fff0691b25 Mon Sep 17 00:00:00 2001 From: rebornix Date: Mon, 25 Jan 2021 14:49:53 -0800 Subject: [PATCH] fix #114048. do not update active kernel if kernel is executed. --- .../contrib/notebook/browser/notebookEditorWidget.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts b/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts index f6809925a59..168c1caa2c3 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts @@ -146,6 +146,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor return this._notebookViewModel?.notebookDocument; } + private _activeKernelExecuted: boolean = false; private _activeKernel: INotebookKernelInfo2 | undefined = undefined; private readonly _onDidChangeKernel = this._register(new Emitter()); readonly onDidChangeKernel: Event = this._onDidChangeKernel.event; @@ -733,6 +734,8 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor this._webview?.element.remove(); this._webview = null; this._list.clear(); + this._activeKernel = undefined; + this._activeKernelExecuted = false; } async beginComputeContributedKernels() { @@ -755,6 +758,11 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor return; } + if (this._activeKernel !== undefined && this._activeKernelExecuted) { + // kernel already executed, we should not change it automatically + return; + } + const provider = this.notebookService.getContributedNotebookProvider(this.viewModel.viewType) || this.notebookService.getContributedNotebookProviders(this.viewModel.uri)[0]; const availableKernels = await this.beginComputeContributedKernels(); @@ -1766,6 +1774,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor } await this._ensureActiveKernel(); + this._activeKernelExecuted = true; await this._activeKernel?.executeNotebookCell!(this.viewModel.uri, undefined); } @@ -1806,6 +1815,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor } await this._ensureActiveKernel(); + this._activeKernelExecuted = true; await this._activeKernel?.executeNotebookCell!(this.viewModel.uri, cell.handle); } -- GitLab