Skip to content

Commit

Permalink
Keep notebook kernel bindings for non-untitled notebooks after they c…
Browse files Browse the repository at this point in the history
…lose (#173352)

And also only persist the selected kernel in the editor view state for untitled notebook editors
Fix #171385
  • Loading branch information
roblourens authored Feb 3, 2023
1 parent 3ab0fb3 commit 8b0df66
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ import { FloatingClickMenu } from 'vs/workbench/browser/codeeditor';
import { IDimension } from 'vs/editor/common/core/dimension';
import { CellFindMatchModel } from 'vs/workbench/contrib/notebook/browser/contrib/find/findModel';
import { INotebookLoggingService } from 'vs/workbench/contrib/notebook/common/notebookLoggingService';
import { Schemas } from 'vs/base/common/network';

const $ = DOM.$;

Expand Down Expand Up @@ -1693,7 +1694,9 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
}
}
state.contributionsState = contributionsState;
state.selectedKernelId = this.activeKernel?.id;
if (this.textModel?.uri.scheme === Schemas.untitled) {
state.selectedKernelId = this.activeKernel?.id;
}

return state;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { IMenu, IMenuService, MenuId } from 'vs/platform/actions/common/actions'
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IAction } from 'vs/base/common/actions';
import { MarshalledId } from 'vs/base/common/marshallingIds';
import { Schemas } from 'vs/base/common/network';

class KernelInfo {

Expand Down Expand Up @@ -134,7 +135,7 @@ export class NotebookKernelService extends Disposable implements INotebookKernel
this._register(_notebookService.onWillRemoveNotebookDocument(notebook => {
const id = NotebookTextModelLikeId.str(notebook);
const kernelId = this._notebookBindings.get(id);
if (kernelId) {
if (kernelId && notebook.uri.scheme === Schemas.untitled) {
this.selectKernelForNotebook(undefined, notebook);
}
this._kernelSourceActionsUpdates.get(id)?.dispose();
Expand Down

0 comments on commit 8b0df66

Please sign in to comment.