Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run by Line: disconnect at last line #6974

Merged
merged 13 commits into from
Aug 9, 2021
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/2 Fixes/6858.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Run by line now stops after running the last line.
1 change: 1 addition & 0 deletions src/client/debugger/jupyter/debuggingManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class Debugger {
name: name,
request: 'attach',
internalConsoleOptions: 'neverOpen',
// justMyCode: false,
__document: document.uri.toString()
},
options
Expand Down
34 changes: 32 additions & 2 deletions src/client/debugger/jupyter/kernelDebugAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter {
private readonly cellToFile = new Map<string, string>();
private readonly sendMessage = new EventEmitter<DebugProtocolMessage>();
private isRunByLine = false;
private stopOnNextContinue = false;
private runByLineThreadId: number = 1;
private runByLineSeq: number = 0;

Expand All @@ -116,8 +117,12 @@ 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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this code work if i have a cell as follows:

def do_something():
    print("Hello")


do_something()

Now, when I'm at the last line, will I be able to step in?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or what if i add a breakpoint at line print("Hello")
& then hit continue, surely it shouldn't stop the run by line, but should step into that code.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I don't remember how it used to work, I'll check

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like run by line in the webview doesn't work on stable. I'll go for it anyway.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new approach covers that scenario

this.stopOnNextContinue = false;
this.runByLineThreadId = content.body.threadId;
this.runByLineSeq = content.seq;
this.runByLineStackTrace();
}
this.sendMessage.fire(msg.content);
}
};
Expand Down Expand Up @@ -166,6 +171,9 @@ 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',
Expand All @@ -176,6 +184,7 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter {
};

this.sendRequestToJupyterSession(message);
this.stopOnNextContinue = true;
}
}

Expand All @@ -194,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) => {
Expand Down Expand Up @@ -313,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);
}

Expand Down