Restart kernel initial implementation (#18835)

* Restart kernel initial implementation

* Update notebook extension TestKernel

* PR comments
This commit is contained in:
Chris LaFreniere
2022-03-29 12:56:52 -07:00
committed by GitHub
parent 8537a30996
commit af3d307d40
14 changed files with 95 additions and 14 deletions

View File

@@ -239,6 +239,24 @@ CommandsRegistry.registerCommand({
}
});
CommandsRegistry.registerCommand({
id: 'notebook.restartKernel',
handler: async (accessor: ServicesAccessor) => {
const editorService: IEditorService = accessor.get(IEditorService);
if (editorService.activeEditor instanceof NotebookInput) {
await editorService.activeEditor.notebookModel?.clientSession?.restart();
}
}
});
MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
command: {
id: 'notebook.restartKernel',
title: localize('restartNotebookKernel', "Restart Notebook Kernel"),
},
when: ContextKeyExpr.and(ActiveEditorContext.isEqualTo(NotebookEditor.ID))
});
MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
command: {
id: TOGGLE_TAB_FOCUS_COMMAND_ID,

View File

@@ -168,6 +168,10 @@ class EmptyKernel implements nb.IKernel {
interrupt(): Thenable<void> {
return Promise.resolve(undefined);
}
restart(): Thenable<void> {
return Promise.resolve(undefined);
}
}
export class EmptyFuture implements FutureInternal {

View File

@@ -353,7 +353,7 @@ export class ClientSessionStub implements IClientSession {
selectKernel(): Promise<void> {
throw new Error('Method not implemented.');
}
restart(): Promise<boolean> {
restart(): Promise<void> {
throw new Error('Method not implemented.');
}
setPath(path: string): Promise<void> {
@@ -464,6 +464,9 @@ export class KernelStub implements nb.IKernel {
interrupt(): Thenable<void> {
throw new Error('Method not implemented.');
}
restart(): Thenable<void> {
throw new Error('Method not implemented.');
}
}
export class FutureStub implements nb.IFuture {