From 22a6b72a3282a961c15c2e141be40f64a01602e7 Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Thu, 27 Oct 2022 12:42:26 -0700 Subject: [PATCH] Fix restart when the notebook editor is not active. Skip ipykernel check on restart to avoiding needing an editor. Fix #11789 --- .../debugger/controllers/restartController.ts | 2 +- src/notebooks/debugger/debuggingManager.ts | 15 ++++++++++----- src/notebooks/debugger/debuggingTypes.ts | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/notebooks/debugger/controllers/restartController.ts b/src/notebooks/debugger/controllers/restartController.ts index 4de1f8d026c..b0bb124aa50 100644 --- a/src/notebooks/debugger/controllers/restartController.ts +++ b/src/notebooks/debugger/controllers/restartController.ts @@ -47,7 +47,7 @@ export class RestartController implements IDebuggingDelegate { .disconnect() .then(() => { this.trace('restart', 'doRestart'); - return this.debuggingManager.tryToStartDebugging(this.mode, this.debugCell); + return this.debuggingManager.tryToStartDebugging(this.mode, this.debugCell, true); }) .catch((err) => { this.error('restart', `Error restarting: ${err}`); diff --git a/src/notebooks/debugger/debuggingManager.ts b/src/notebooks/debugger/debuggingManager.ts index 65c9b0025f4..d12ee298f23 100644 --- a/src/notebooks/debugger/debuggingManager.ts +++ b/src/notebooks/debugger/debuggingManager.ts @@ -124,15 +124,20 @@ export class DebuggingManager this.debugDocuments.set(Array.from(debugDocumentUris.values())).ignoreErrors(); } - public async tryToStartDebugging(mode: KernelDebugMode, cell: NotebookCell) { + public async tryToStartDebugging(mode: KernelDebugMode, cell: NotebookCell, skipIpykernelCheck = false) { traceInfo(`Starting debugging with mode ${mode}`); - const ipykernelResult = await this.checkIpykernelAndPrompt(cell); - if (ipykernelResult === IpykernelCheckResult.Ok) { - if (mode === KernelDebugMode.RunByLine || mode === KernelDebugMode.Cell) { - await this.startDebuggingCell(mode, cell!); + if (!skipIpykernelCheck) { + const ipykernelResult = await this.checkIpykernelAndPrompt(cell); + if (ipykernelResult !== IpykernelCheckResult.Ok) { + traceInfo(`Ipykernel check failed: ${IpykernelCheckResult[ipykernelResult]}`); + return; } } + + if (mode === KernelDebugMode.RunByLine || mode === KernelDebugMode.Cell) { + await this.startDebuggingCell(mode, cell!); + } } public runByLineNext(cell: NotebookCell) { diff --git a/src/notebooks/debugger/debuggingTypes.ts b/src/notebooks/debugger/debuggingTypes.ts index e218a59b2b6..dc80567c4d8 100644 --- a/src/notebooks/debugger/debuggingTypes.ts +++ b/src/notebooks/debugger/debuggingTypes.ts @@ -82,7 +82,7 @@ export interface IDebuggingManager { export const INotebookDebuggingManager = Symbol('INotebookDebuggingManager'); export interface INotebookDebuggingManager extends IDebuggingManager { - tryToStartDebugging(mode: KernelDebugMode, cell: NotebookCell): Promise; + tryToStartDebugging(mode: KernelDebugMode, cell: NotebookCell, skipIpykernelCheck?: boolean): Promise; runByLineNext(cell: NotebookCell): void; runByLineStop(cell: NotebookCell): void; }