From 49bfad58773619dfe69ffa3446320d2f100fabc9 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 5 Aug 2021 11:41:50 -0700 Subject: [PATCH 01/11] stop the run by line session if we hit continue on the last line --- package.json | 8 +-- .../debugger/jupyter/kernelDebugAdapter.ts | 63 +++++++++++++++---- 2 files changed, 56 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index faf19c5bde5..003093c7ae2 100644 --- a/package.json +++ b/package.json @@ -948,23 +948,23 @@ { "command": "jupyter.debugNotebook", "group": "navigation@3", - "when": "notebookType == 'jupyter-notebook' && isWorkspaceTrusted && jupyter.notebookeditor.canDebug && config.jupyter.experimental.debugging" + "when": "notebookType == 'jupyter-notebook' && isWorkspaceTrusted && config.jupyter.experimental.debugging" } ], "notebook/cell/title": [ { "command": "jupyter.runByLine", - "when": "notebookType == jupyter-notebook && notebookCellType == code && isWorkspaceTrusted && jupyter.notebookeditor.canDebug && !jupyter.notebookeditor.runByLineInProgress && config.jupyter.experimental.debugging", + "when": "notebookType == jupyter-notebook && notebookCellType == code && isWorkspaceTrusted && !jupyter.notebookeditor.runByLineInProgress && config.jupyter.experimental.debugging", "group": "inline/cell@0" }, { "command": "jupyter.runByLineContinue", - "when": "notebookType == jupyter-notebook && notebookCellType == code && isWorkspaceTrusted && jupyter.notebookeditor.canDebug && jupyter.notebookeditor.runByLineInProgress && config.jupyter.experimental.debugging", + "when": "notebookType == jupyter-notebook && notebookCellType == code && isWorkspaceTrusted && jupyter.notebookeditor.runByLineInProgress && config.jupyter.experimental.debugging", "group": "inline/cell@0" }, { "command": "jupyter.runByLineStop", - "when": "notebookType == jupyter-notebook && notebookCellType == code && isWorkspaceTrusted && jupyter.notebookeditor.canDebug && jupyter.notebookeditor.runByLineInProgress && config.jupyter.experimental.debugging", + "when": "notebookType == jupyter-notebook && notebookCellType == code && isWorkspaceTrusted && jupyter.notebookeditor.runByLineInProgress && config.jupyter.experimental.debugging", "group": "inline/cell@0" } ], diff --git a/src/client/debugger/jupyter/kernelDebugAdapter.ts b/src/client/debugger/jupyter/kernelDebugAdapter.ts index ab15e39b957..294c75ba47c 100644 --- a/src/client/debugger/jupyter/kernelDebugAdapter.ts +++ b/src/client/debugger/jupyter/kernelDebugAdapter.ts @@ -96,6 +96,7 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter { private readonly cellToFile = new Map(); private readonly sendMessage = new EventEmitter(); private isRunByLine = false; + private runbyLineLastLine = false; private runByLineThreadId: number = 1; private runByLineSeq: number = 0; @@ -116,8 +117,11 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter { // eslint-disable-next-line @typescript-eslint/no-explicit-any const content = msg.content as any; if (content.event === 'stopped') { - this.runByLineThreadId = content.body.threadId; - this.runByLineSeq = content.seq; + if (this.isRunByLine) { + this.runByLineThreadId = content.body.threadId; + this.runByLineSeq = content.seq; + this.runByLineStackTrace(); + } this.sendMessage.fire(msg.content); } }; @@ -166,16 +170,21 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter { public runByLineContinue() { if (this.isRunByLine) { - const message: DebugProtocol.StepInRequest = { - seq: this.runByLineSeq, - type: 'request', - command: 'stepIn', - arguments: { - threadId: this.runByLineThreadId - } - }; + if (this.runbyLineLastLine) { + this.runbyLineLastLine = false; + this.runByLineStop(); + } else { + const message: DebugProtocol.StepInRequest = { + seq: this.runByLineSeq, + type: 'request', + command: 'stepIn', + arguments: { + threadId: this.runByLineThreadId + } + }; - this.sendRequestToJupyterSession(message); + this.sendRequestToJupyterSession(message); + } } } @@ -194,6 +203,19 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter { } } + private runByLineStackTrace() { + const message: DebugProtocol.StackTraceRequest = { + seq: this.runByLineSeq, + type: 'request', + command: 'stackTrace', + arguments: { + threadId: this.runByLineThreadId + } + }; + + this.sendRequestToJupyterSession(message); + } + dispose() { // clean temp files this.cellToFile.forEach((tempPath) => { @@ -313,6 +335,25 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter { } }); + if ((message as DebugProtocol.StackTraceResponse).command === 'stackTrace') { + (message as DebugProtocol.StackTraceResponse).body.stackFrames.forEach((sf) => { + // Check if we're stopped at the last line + let currentCell: NotebookCell | undefined; + this.notebookDocument.getCells().forEach((cell) => { + const index = sf.source?.path!.indexOf('#ch'); + if (index) { + const fragment = sf.source?.path!.substring(index + 1); + if (cell.document.uri.fragment === fragment) { + currentCell = cell; + } + } + }); + if (currentCell && sf.line === currentCell.document.lineCount) { + this.runbyLineLastLine = true; + } + }); + } + this.sendMessage.fire(message); } From 365656987efebee3937294f41f451da09c48e385 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 5 Aug 2021 11:43:32 -0700 Subject: [PATCH 02/11] news --- news/2 Fixes/6858.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/2 Fixes/6858.md diff --git a/news/2 Fixes/6858.md b/news/2 Fixes/6858.md new file mode 100644 index 00000000000..9f9370254c8 --- /dev/null +++ b/news/2 Fixes/6858.md @@ -0,0 +1 @@ +Run by line now stops after running the last line. From 5d75894eb46e2e6b083d1ad106f805391eee0250 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 5 Aug 2021 11:45:18 -0700 Subject: [PATCH 03/11] oops --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 003093c7ae2..faf19c5bde5 100644 --- a/package.json +++ b/package.json @@ -948,23 +948,23 @@ { "command": "jupyter.debugNotebook", "group": "navigation@3", - "when": "notebookType == 'jupyter-notebook' && isWorkspaceTrusted && config.jupyter.experimental.debugging" + "when": "notebookType == 'jupyter-notebook' && isWorkspaceTrusted && jupyter.notebookeditor.canDebug && config.jupyter.experimental.debugging" } ], "notebook/cell/title": [ { "command": "jupyter.runByLine", - "when": "notebookType == jupyter-notebook && notebookCellType == code && isWorkspaceTrusted && !jupyter.notebookeditor.runByLineInProgress && config.jupyter.experimental.debugging", + "when": "notebookType == jupyter-notebook && notebookCellType == code && isWorkspaceTrusted && jupyter.notebookeditor.canDebug && !jupyter.notebookeditor.runByLineInProgress && config.jupyter.experimental.debugging", "group": "inline/cell@0" }, { "command": "jupyter.runByLineContinue", - "when": "notebookType == jupyter-notebook && notebookCellType == code && isWorkspaceTrusted && jupyter.notebookeditor.runByLineInProgress && config.jupyter.experimental.debugging", + "when": "notebookType == jupyter-notebook && notebookCellType == code && isWorkspaceTrusted && jupyter.notebookeditor.canDebug && jupyter.notebookeditor.runByLineInProgress && config.jupyter.experimental.debugging", "group": "inline/cell@0" }, { "command": "jupyter.runByLineStop", - "when": "notebookType == jupyter-notebook && notebookCellType == code && isWorkspaceTrusted && jupyter.notebookeditor.runByLineInProgress && config.jupyter.experimental.debugging", + "when": "notebookType == jupyter-notebook && notebookCellType == code && isWorkspaceTrusted && jupyter.notebookeditor.canDebug && jupyter.notebookeditor.runByLineInProgress && config.jupyter.experimental.debugging", "group": "inline/cell@0" } ], From 4fe31492a09d4272043d5d12b033ead7cb85393c Mon Sep 17 00:00:00 2001 From: David Date: Thu, 5 Aug 2021 14:32:36 -0700 Subject: [PATCH 04/11] use helper function --- .../debugger/jupyter/kernelDebugAdapter.ts | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/client/debugger/jupyter/kernelDebugAdapter.ts b/src/client/debugger/jupyter/kernelDebugAdapter.ts index 294c75ba47c..95d044ec9bc 100644 --- a/src/client/debugger/jupyter/kernelDebugAdapter.ts +++ b/src/client/debugger/jupyter/kernelDebugAdapter.ts @@ -338,17 +338,8 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter { if ((message as DebugProtocol.StackTraceResponse).command === 'stackTrace') { (message as DebugProtocol.StackTraceResponse).body.stackFrames.forEach((sf) => { // Check if we're stopped at the last line - let currentCell: NotebookCell | undefined; - this.notebookDocument.getCells().forEach((cell) => { - const index = sf.source?.path!.indexOf('#ch'); - if (index) { - const fragment = sf.source?.path!.substring(index + 1); - if (cell.document.uri.fragment === fragment) { - currentCell = cell; - } - } - }); - if (currentCell && sf.line === currentCell.document.lineCount) { + let currentCell = this.findCurrentCellFromStackFrame(sf); + if (currentCell && currentCell.document.lineCount === sf.line) { this.runbyLineLastLine = true; } }); @@ -488,4 +479,21 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter { // Run cell await this.commandManager.executeCommand('notebook.cell.execute'); } + + private findCurrentCellFromStackFrame(stackFrame: DebugProtocol.StackFrame): NotebookCell | undefined { + // path.basename() + let currentCell: NotebookCell | undefined; + const index = stackFrame.source?.path!.indexOf('#ch'); + if (index) { + const fragment = stackFrame.source?.path!.substring(index + 1); + this.notebookDocument.getCells().forEach((cell) => { + if (cell.document.uri.fragment === fragment) { + currentCell = cell; + return; + } + }); + } + + return currentCell; + } } From 998497c99492e014d741ed29e85aa3aca6c0207b Mon Sep 17 00:00:00 2001 From: David Date: Thu, 5 Aug 2021 14:41:26 -0700 Subject: [PATCH 05/11] use path instead of looking in strings --- src/client/debugger/jupyter/kernelDebugAdapter.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/client/debugger/jupyter/kernelDebugAdapter.ts b/src/client/debugger/jupyter/kernelDebugAdapter.ts index 95d044ec9bc..ae790d03e88 100644 --- a/src/client/debugger/jupyter/kernelDebugAdapter.ts +++ b/src/client/debugger/jupyter/kernelDebugAdapter.ts @@ -481,13 +481,12 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter { } private findCurrentCellFromStackFrame(stackFrame: DebugProtocol.StackFrame): NotebookCell | undefined { - // path.basename() let currentCell: NotebookCell | undefined; - const index = stackFrame.source?.path!.indexOf('#ch'); - if (index) { - const fragment = stackFrame.source?.path!.substring(index + 1); + + if (stackFrame.source?.path) { + const sfPath = path.basename(stackFrame.source?.path); this.notebookDocument.getCells().forEach((cell) => { - if (cell.document.uri.fragment === fragment) { + if (path.basename(cell.document.uri.toString()) === sfPath) { currentCell = cell; return; } From 1a77c38e92e235f0ec4d3daa2f98509a18b0a9ad Mon Sep 17 00:00:00 2001 From: David Date: Thu, 5 Aug 2021 19:35:59 -0700 Subject: [PATCH 06/11] change approach --- .../debugger/jupyter/kernelDebugAdapter.ts | 69 ++++--------------- 1 file changed, 15 insertions(+), 54 deletions(-) diff --git a/src/client/debugger/jupyter/kernelDebugAdapter.ts b/src/client/debugger/jupyter/kernelDebugAdapter.ts index ae790d03e88..072b70d2907 100644 --- a/src/client/debugger/jupyter/kernelDebugAdapter.ts +++ b/src/client/debugger/jupyter/kernelDebugAdapter.ts @@ -96,7 +96,7 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter { private readonly cellToFile = new Map(); private readonly sendMessage = new EventEmitter(); private isRunByLine = false; - private runbyLineLastLine = false; + private stopOnNextContinue = false; private runByLineThreadId: number = 1; private runByLineSeq: number = 0; @@ -118,9 +118,9 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter { const content = msg.content as any; if (content.event === 'stopped') { if (this.isRunByLine) { + this.stopOnNextContinue = false; this.runByLineThreadId = content.body.threadId; this.runByLineSeq = content.seq; - this.runByLineStackTrace(); } this.sendMessage.fire(msg.content); } @@ -170,21 +170,21 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter { public runByLineContinue() { if (this.isRunByLine) { - if (this.runbyLineLastLine) { - this.runbyLineLastLine = false; + if (this.stopOnNextContinue) { this.runByLineStop(); - } else { - const message: DebugProtocol.StepInRequest = { - seq: this.runByLineSeq, - type: 'request', - command: 'stepIn', - arguments: { - threadId: this.runByLineThreadId - } - }; - - this.sendRequestToJupyterSession(message); } + const message: DebugProtocol.StepInRequest = { + seq: this.runByLineSeq, + type: 'request', + command: 'stepIn', + arguments: { + threadId: this.runByLineThreadId + } + }; + + this.sendRequestToJupyterSession(message); + + this.stopOnNextContinue = true; } } @@ -203,19 +203,6 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter { } } - private runByLineStackTrace() { - const message: DebugProtocol.StackTraceRequest = { - seq: this.runByLineSeq, - type: 'request', - command: 'stackTrace', - arguments: { - threadId: this.runByLineThreadId - } - }; - - this.sendRequestToJupyterSession(message); - } - dispose() { // clean temp files this.cellToFile.forEach((tempPath) => { @@ -335,16 +322,6 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter { } }); - if ((message as DebugProtocol.StackTraceResponse).command === 'stackTrace') { - (message as DebugProtocol.StackTraceResponse).body.stackFrames.forEach((sf) => { - // Check if we're stopped at the last line - let currentCell = this.findCurrentCellFromStackFrame(sf); - if (currentCell && currentCell.document.lineCount === sf.line) { - this.runbyLineLastLine = true; - } - }); - } - this.sendMessage.fire(message); } @@ -479,20 +456,4 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter { // Run cell await this.commandManager.executeCommand('notebook.cell.execute'); } - - private findCurrentCellFromStackFrame(stackFrame: DebugProtocol.StackFrame): NotebookCell | undefined { - let currentCell: NotebookCell | undefined; - - if (stackFrame.source?.path) { - const sfPath = path.basename(stackFrame.source?.path); - this.notebookDocument.getCells().forEach((cell) => { - if (path.basename(cell.document.uri.toString()) === sfPath) { - currentCell = cell; - return; - } - }); - } - - return currentCell; - } } From e29291c58f4d2bfade41f6bd1b6bc771445f7e4f Mon Sep 17 00:00:00 2001 From: David Date: Thu, 5 Aug 2021 19:37:53 -0700 Subject: [PATCH 07/11] oops --- src/client/debugger/jupyter/kernelDebugAdapter.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/client/debugger/jupyter/kernelDebugAdapter.ts b/src/client/debugger/jupyter/kernelDebugAdapter.ts index 072b70d2907..bbd094fef54 100644 --- a/src/client/debugger/jupyter/kernelDebugAdapter.ts +++ b/src/client/debugger/jupyter/kernelDebugAdapter.ts @@ -183,7 +183,6 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter { }; this.sendRequestToJupyterSession(message); - this.stopOnNextContinue = true; } } From 0ddee8b1aa3f1bf09ebbb8b2ecb0e7b9b365084d Mon Sep 17 00:00:00 2001 From: David Kutugata Date: Sat, 7 Aug 2021 10:41:49 -0700 Subject: [PATCH 08/11] IDK --- .../debugger/jupyter/debuggingManager.ts | 1 + .../debugger/jupyter/kernelDebugAdapter.ts | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/client/debugger/jupyter/debuggingManager.ts b/src/client/debugger/jupyter/debuggingManager.ts index d4ec59416de..6d37a0a4917 100644 --- a/src/client/debugger/jupyter/debuggingManager.ts +++ b/src/client/debugger/jupyter/debuggingManager.ts @@ -55,6 +55,7 @@ class Debugger { name: name, request: 'attach', internalConsoleOptions: 'neverOpen', + // justMyCode: false, __document: document.uri.toString() }, options diff --git a/src/client/debugger/jupyter/kernelDebugAdapter.ts b/src/client/debugger/jupyter/kernelDebugAdapter.ts index bbd094fef54..51ed26f01f7 100644 --- a/src/client/debugger/jupyter/kernelDebugAdapter.ts +++ b/src/client/debugger/jupyter/kernelDebugAdapter.ts @@ -121,6 +121,7 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter { this.stopOnNextContinue = false; this.runByLineThreadId = content.body.threadId; this.runByLineSeq = content.seq; + this.runByLineStackTrace(); } this.sendMessage.fire(msg.content); } @@ -202,6 +203,19 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter { } } + private runByLineStackTrace(): void { + const message: DebugProtocol.StackTraceRequest = { + seq: this.runByLineSeq, + type: 'request', + command: 'stackTrace', + arguments: { + threadId: this.runByLineThreadId + } + }; + + this.sendRequestToJupyterSession(message); + } + dispose() { // clean temp files this.cellToFile.forEach((tempPath) => { @@ -321,6 +335,14 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter { } }); + if ((message as DebugProtocol.StackTraceResponse).command === 'stackTrace') { + (message as DebugProtocol.StackTraceResponse).body.stackFrames.forEach((sf) => { + console.log(sf); + // this.runByLineScope(sf.id); + // check if sf.source?.path is on the cell, if its not, stepInto again + }); + } + this.sendMessage.fire(message); } From aa59a5cceb41d6a301dff19dc7e39cc941b35db7 Mon Sep 17 00:00:00 2001 From: David Date: Mon, 9 Aug 2021 13:18:41 -0700 Subject: [PATCH 09/11] use notebooks onDidChangeNotebookCellExecutionState event --- .../debugger/jupyter/kernelDebugAdapter.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/client/debugger/jupyter/kernelDebugAdapter.ts b/src/client/debugger/jupyter/kernelDebugAdapter.ts index bbd094fef54..cafdec04ad2 100644 --- a/src/client/debugger/jupyter/kernelDebugAdapter.ts +++ b/src/client/debugger/jupyter/kernelDebugAdapter.ts @@ -10,7 +10,10 @@ import { NotebookCell, Event, EventEmitter, - DebugProtocolMessage + DebugProtocolMessage, + notebooks, + NotebookCellExecutionStateChangeEvent, + NotebookCellExecutionState } from 'vscode'; import { DebugProtocol } from 'vscode-debugprotocol'; import { randomBytes } from 'crypto'; @@ -96,7 +99,6 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter { private readonly cellToFile = new Map(); private readonly sendMessage = new EventEmitter(); private isRunByLine = false; - private stopOnNextContinue = false; private runByLineThreadId: number = 1; private runByLineSeq: number = 0; @@ -118,7 +120,6 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter { const content = msg.content as any; if (content.event === 'stopped') { if (this.isRunByLine) { - this.stopOnNextContinue = false; this.runByLineThreadId = content.body.threadId; this.runByLineSeq = content.seq; } @@ -128,6 +129,12 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter { this.jupyterSession.onIOPubMessage(iopubHandler); void this.dumpCellsThatRanBeforeDebuggingBegan(); + notebooks.onDidChangeNotebookCellExecutionState((cellStateChange: NotebookCellExecutionStateChangeEvent) => { + // If a cell has moved to idle, stop the run by line session + if (cellStateChange.state === NotebookCellExecutionState.Idle) { + this.runByLineStop(); + } + }, this); } async handleMessage(message: DebugProtocol.ProtocolMessage) { @@ -170,9 +177,6 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter { public runByLineContinue() { if (this.isRunByLine) { - if (this.stopOnNextContinue) { - this.runByLineStop(); - } const message: DebugProtocol.StepInRequest = { seq: this.runByLineSeq, type: 'request', @@ -183,7 +187,6 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter { }; this.sendRequestToJupyterSession(message); - this.stopOnNextContinue = true; } } From bde7a901e4713454bdb8d495e15cf3e6d66154cc Mon Sep 17 00:00:00 2001 From: David Date: Mon, 9 Aug 2021 13:31:49 -0700 Subject: [PATCH 10/11] add disposables --- .../debugger/jupyter/kernelDebugAdapter.ts | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/client/debugger/jupyter/kernelDebugAdapter.ts b/src/client/debugger/jupyter/kernelDebugAdapter.ts index cafdec04ad2..1154f766184 100644 --- a/src/client/debugger/jupyter/kernelDebugAdapter.ts +++ b/src/client/debugger/jupyter/kernelDebugAdapter.ts @@ -24,6 +24,7 @@ import { ICommandManager } from '../../common/application/types'; import { traceError } from '../../common/logger'; import { IFileSystem } from '../../common/platform/types'; import { IKernelDebugAdapter } from '../types'; +import { IDisposable } from '../../common/types'; const debugRequest = (message: DebugProtocol.Request, jupyterSessionId: string): KernelMessage.IDebugRequestMsg => { return { @@ -94,13 +95,14 @@ interface debugInfoResponseBreakpoint { // For info on the custom requests implemented by jupyter see: // https://jupyter-client.readthedocs.io/en/stable/messaging.html#debug-request // https://jupyter-client.readthedocs.io/en/stable/messaging.html#additions-to-the-dap -export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter { +export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter, IDisposable { private readonly fileToCell = new Map(); private readonly cellToFile = new Map(); private readonly sendMessage = new EventEmitter(); private isRunByLine = false; private runByLineThreadId: number = 1; private runByLineSeq: number = 0; + private readonly disposables: IDisposable[] = []; onDidSendMessage: Event = this.sendMessage.event; @@ -129,12 +131,16 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter { this.jupyterSession.onIOPubMessage(iopubHandler); void this.dumpCellsThatRanBeforeDebuggingBegan(); - notebooks.onDidChangeNotebookCellExecutionState((cellStateChange: NotebookCellExecutionStateChangeEvent) => { - // If a cell has moved to idle, stop the run by line session - if (cellStateChange.state === NotebookCellExecutionState.Idle) { - this.runByLineStop(); - } - }, this); + notebooks.onDidChangeNotebookCellExecutionState( + (cellStateChange: NotebookCellExecutionStateChangeEvent) => { + // If a cell has moved to idle, stop the run by line session + if (cellStateChange.state === NotebookCellExecutionState.Idle) { + this.runByLineStop(); + } + }, + this, + this.disposables + ); } async handleMessage(message: DebugProtocol.ProtocolMessage) { @@ -206,6 +212,7 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter { } dispose() { + this.disposables.forEach((d) => d.dispose()); // clean temp files this.cellToFile.forEach((tempPath) => { const norm = path.normalize(tempPath); From c4236ef7abab372768df5847d0d6b2ce385865c4 Mon Sep 17 00:00:00 2001 From: David Date: Mon, 9 Aug 2021 13:34:03 -0700 Subject: [PATCH 11/11] undo unnecessary changes --- .../debugger/jupyter/debuggingManager.ts | 1 - .../debugger/jupyter/kernelDebugAdapter.ts | 22 ------------------- 2 files changed, 23 deletions(-) diff --git a/src/client/debugger/jupyter/debuggingManager.ts b/src/client/debugger/jupyter/debuggingManager.ts index 6d37a0a4917..d4ec59416de 100644 --- a/src/client/debugger/jupyter/debuggingManager.ts +++ b/src/client/debugger/jupyter/debuggingManager.ts @@ -55,7 +55,6 @@ class Debugger { name: name, request: 'attach', internalConsoleOptions: 'neverOpen', - // justMyCode: false, __document: document.uri.toString() }, options diff --git a/src/client/debugger/jupyter/kernelDebugAdapter.ts b/src/client/debugger/jupyter/kernelDebugAdapter.ts index af8dce352fa..1154f766184 100644 --- a/src/client/debugger/jupyter/kernelDebugAdapter.ts +++ b/src/client/debugger/jupyter/kernelDebugAdapter.ts @@ -124,7 +124,6 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter, ID if (this.isRunByLine) { this.runByLineThreadId = content.body.threadId; this.runByLineSeq = content.seq; - this.runByLineStackTrace(); } this.sendMessage.fire(msg.content); } @@ -212,19 +211,6 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter, ID } } - private runByLineStackTrace(): void { - const message: DebugProtocol.StackTraceRequest = { - seq: this.runByLineSeq, - type: 'request', - command: 'stackTrace', - arguments: { - threadId: this.runByLineThreadId - } - }; - - this.sendRequestToJupyterSession(message); - } - dispose() { this.disposables.forEach((d) => d.dispose()); // clean temp files @@ -345,14 +331,6 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter, ID } }); - if ((message as DebugProtocol.StackTraceResponse).command === 'stackTrace') { - (message as DebugProtocol.StackTraceResponse).body.stackFrames.forEach((sf) => { - console.log(sf); - // this.runByLineScope(sf.id); - // check if sf.source?.path is on the cell, if its not, stepInto again - }); - } - this.sendMessage.fire(message); }