Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Connect Breakpoints widget with NoteBook #36

Merged
merged 46 commits into from Oct 3, 2019
Merged

Connect Breakpoints widget with NoteBook #36

merged 46 commits into from Oct 3, 2019

Conversation

KsavinN
Copy link
Collaborator

@KsavinN KsavinN commented Sep 2, 2019

breakpoints

@KsavinN KsavinN requested review from jtpio and afshin September 4, 2019 08:00

protected removeAllGutterBreakpoints(cell: CodeCell) {
const editor = cell.editor as CodeMirrorEditor;
editor.editor.getDoc().eachLine(line => {
Copy link
Member

Choose a reason for hiding this comment

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

Thinking out loud: I was wondering whether there was a way to avoid the editor.editor pattern and use the editor wrapper instead (probably not since we need to access the CodeMirror methods directly)

super();

this.model = new Breakpoints.IModel(MOCK_BREAKPOINTS);
this.model = new Breakpoints.IModel([] as Breakpoints.IBreakpoint[]);
Copy link
Member

Choose a reason for hiding this comment

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

Is the type casting necessary here?

notebook: INotebookTracker;
previousCell: CodeCell;
previousLineCount: number;
cellsBreakpoints: any = {};
Copy link
Member

Choose a reason for hiding this comment

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

This needs a proper type instead of any.

}
this.previousLineCount = linesNumber;
}
// eage case for backspace line 2
Copy link
Member

Choose a reason for hiding this comment

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

what does this edge case look like?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If you set a breakpoint in line 1 and after that remove line 2 in editor gutter remove automatically breakpoint from line 1.

);

if (!breakpoint && !removeGutter) {
this.model.breakpoint = {
Copy link
Member

Choose a reason for hiding this comment

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

This looks like the model can only handle 1 breakpoint at a time. Maybe using a more explicit method such as addBreakpoint would be more appropriate?

const breakpoints = this.breakpoints.filter(
ele => ele.line !== breakpoint.line
);
this.breakpoints = [];
Copy link
Member

Choose a reason for hiding this comment

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

Is this line necessary?

ele.line = lineEnter <= ele.line ? ele.line + howMany : ele.line;
return ele;
});
this.breakpoints = [];
Copy link
Member

@jtpio jtpio Sep 4, 2019

Choose a reason for hiding this comment

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

Same question as above

src/debugger.ts Outdated
@@ -64,6 +70,10 @@ export namespace Debugger {
return this._isDisposed;
}

get notebook() {
Copy link
Member

Choose a reason for hiding this comment

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

This seems to return a NotebookTracker instead of Notebook (can lead to some confusion for users of this API)

noteTracker: INotebookTracker;
previousCell: CodeCell;
previousLineCount: number;
cellsBreakpoints: { [id: string]: Breakpoints.IBreakpoint[] } = {};
Copy link
Member

Choose a reason for hiding this comment

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

Could we change the name of this to cellBreakpoints where cell is singular, please?

});
}

removeListner(cell: CodeCell) {
Copy link
Member

Choose a reason for hiding this comment

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

typo: removeListner => removeListener

src/debugger.ts Outdated
@@ -45,14 +47,16 @@ export class Debugger extends BoxPanel {
export namespace Debugger {
export interface IOptions {
connector?: IDataConnector<ReadonlyJSONValue>;

noteTracker?: INotebookTracker;
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I understand the reasoning here. Why does the Debugger need a reference to any trackers? The pattern I had in mind was the extension to have the trackers and as those trackers change for it to modify the debugger's handle to individual text editors.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In actual branch, i working on a split this. I get your idea before, these changes I made after the suggestion of Jeremy. I guess tomorrow or on Wednesday I will merge changes to this branch.

Copy link
Member

Choose a reason for hiding this comment

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

Ah okay, great; I'll take a look whenever you're ready for that!

@jtpio
Copy link
Member

jtpio commented Sep 26, 2019

Quickly tested this locally. The "Remove all Breakpoints" button doesn't remove the breakpoints from the cell gutters, but that can be done in a follow-up PR.


addBreakpoint(session: string, type: string, lineInfo: LineInfo) {
const breakpoint: Breakpoints.IBreakpoint = {
line: lineInfo.line,
Copy link
Member

Choose a reason for hiding this comment

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

This seems to return 0 for line number 1?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, good point. I will fix that

Copy link
Member

Choose a reason for hiding this comment

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

👍

this.breakpoints = [];
} else {
const breakpoint = { ...this.breakpoints[0] };
var breakpoints: Breakpoints.IBreakpoint[] = [];
Copy link
Member

Choose a reason for hiding this comment

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

let would be better here:

Suggested change
var breakpoints: Breakpoints.IBreakpoint[] = [];
let breakpoints: Breakpoints.IBreakpoint[] = [];

src/index.ts Show resolved Hide resolved
@@ -153,7 +220,10 @@ const tracker: JupyterFrontEndPlugin<IDebugger> = {
}

const widget = new MainAreaWidget({
content: new Debugger({ connector: state, id })
content: new Debugger({
Copy link
Member

@jtpio jtpio Oct 1, 2019

Choose a reason for hiding this comment

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

Let's add the widget to the main area as well?

For now it's only added to the tracker.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we could do that. But I don't quite know what we can now display in that widget.

Copy link
Member

Choose a reason for hiding this comment

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

Not much for now indeed, but it's still good that it shows up somewhere.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok. I will change that and try to resolve bug which you found.

@jtpio
Copy link
Member

jtpio commented Oct 1, 2019

Sometimes it seems like the breakpoints can't be set (after running the debugger:create command and refreshing the page).

(here the panel was added to the main area with app.shell.add(widget, 'main'))

breakpoints-gutter

@afshin
Copy link
Member

afshin commented Oct 2, 2019

I propose we merge this and iterate on it so that @jtpio and I can work off this branch.

Copy link
Member

@afshin afshin left a comment

Choose a reason for hiding this comment

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

Let's merge this and iterate.

@JohanMabille
Copy link
Member

JohanMabille commented Oct 3, 2019

I can reproduce the bug reported by @jtpio in a deterministic way: I can never set any breakpoint (I have checked that the extension is correctly installed and enabled). Also for an unknown reason, the display of line numbers is disabled by default.

I've tested with this prototype (to see if I could quickly port a fix) I can set breakpoints, but only in cells that have not been executed yet.

NOTE: I'm testing with Google Chrome.

@KsavinN KsavinN merged commit 302c3f3 into jupyterlab:master Oct 3, 2019
@KsavinN
Copy link
Collaborator Author

KsavinN commented Oct 3, 2019

I can reproduce the bug reported by @jtpio in a deterministic way: I can never set any breakpoint (I have checked that the extension is correctly installed and enabled). Also for an unknown reason, the display of line numbers is disabled by default.

I've tested with this prototype (to see if I could quickly port a fix) I can set breakpoints, but only in cells that have not been executed yet.

NOTE: I'm testing with Google Chrome.

@JohanMabille Thank you for help and opinion. I will try to reproduce issues. "Also for an unknown reason, the display of line numbers is disabled by default." - I was thought that the default state of display line numbers is disabled.

@JohanMabille
Copy link
Member

JohanMabille commented Oct 3, 2019

@KsavinN The bug I had was my fault, I didn't start the debugger with the "hidden" command. Now I can set breakpoints and reproduce the issue described by @jtpio

@@ -52,6 +52,7 @@
"@phosphor/coreutils": "^1.3.1",
"@phosphor/disposable": "^1.2.0",
"@phosphor/widgets": "^1.8.0",
"@types/codemirror": "0.0.76",
Copy link
Member

Choose a reason for hiding this comment

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

This should go to devDependencies

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants