mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 13:29:44 +00:00
Merge pull request #142751 from amunger/preSelectKernelforIW
don't attempt to update a document that doesn't exist yet
This commit is contained in:
commit
f8d80c9383
|
@ -386,7 +386,7 @@ registerAction2(class extends Action2 {
|
|||
const allKernels = kernelService.getMatchingKernel({ uri: notebookUri, viewType: 'interactive' }).all;
|
||||
const preferredKernel = allKernels.find(kernel => kernel.id === id);
|
||||
if (preferredKernel) {
|
||||
kernelService.selectKernelForNotebook(preferredKernel, { uri: notebookUri, viewType: 'interactive' });
|
||||
kernelService.preselectKernelForNotebook(preferredKernel, { uri: notebookUri, viewType: 'interactive' });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -225,6 +225,15 @@ export class NotebookKernelService extends Disposable implements INotebookKernel
|
|||
}
|
||||
}
|
||||
|
||||
preselectKernelForNotebook(kernel: INotebookKernel, notebook: INotebookTextModelLike): void {
|
||||
const key = NotebookTextModelLikeId.str(notebook);
|
||||
const oldKernel = this._notebookBindings.get(key);
|
||||
if (oldKernel !== kernel?.id) {
|
||||
this._notebookBindings.set(key, kernel.id);
|
||||
this._persistMementos();
|
||||
}
|
||||
}
|
||||
|
||||
updateKernelNotebookAffinity(kernel: INotebookKernel, notebook: URI, preference: number | undefined): void {
|
||||
const info = this._kernels.get(kernel.id);
|
||||
if (!info) {
|
||||
|
|
|
@ -81,6 +81,11 @@ export interface INotebookKernelService {
|
|||
*/
|
||||
selectKernelForNotebook(kernel: INotebookKernel, notebook: INotebookTextModelLike): void;
|
||||
|
||||
/**
|
||||
* Set the kernel that a notebook should use when it starts up
|
||||
*/
|
||||
preselectKernelForNotebook(kernel: INotebookKernel, notebook: INotebookTextModelLike): void;
|
||||
|
||||
/**
|
||||
* Bind a notebook type to a kernel.
|
||||
* @param viewType
|
||||
|
|
Loading…
Reference in a new issue