Connect Breakpoints widget with NoteBook #36
Conversation
KsavinN
commented
Sep 2, 2019
•
edited by afshin
edited by afshin
src/breakpoints/index.ts
Outdated
|
||
protected removeAllGutterBreakpoints(cell: CodeCell) { | ||
const editor = cell.editor as CodeMirrorEditor; | ||
editor.editor.getDoc().eachLine(line => { |
There was a problem hiding this comment.
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)
src/breakpoints/index.ts
Outdated
super(); | ||
|
||
this.model = new Breakpoints.IModel(MOCK_BREAKPOINTS); | ||
this.model = new Breakpoints.IModel([] as Breakpoints.IBreakpoint[]); |
There was a problem hiding this comment.
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?
src/breakpoints/index.ts
Outdated
notebook: INotebookTracker; | ||
previousCell: CodeCell; | ||
previousLineCount: number; | ||
cellsBreakpoints: any = {}; |
There was a problem hiding this comment.
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
.
src/breakpoints/index.ts
Outdated
} | ||
this.previousLineCount = linesNumber; | ||
} | ||
// eage case for backspace line 2 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
src/breakpoints/index.ts
Outdated
); | ||
|
||
if (!breakpoint && !removeGutter) { | ||
this.model.breakpoint = { |
There was a problem hiding this comment.
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?
src/breakpoints/index.ts
Outdated
const breakpoints = this.breakpoints.filter( | ||
ele => ele.line !== breakpoint.line | ||
); | ||
this.breakpoints = []; |
There was a problem hiding this comment.
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 = []; |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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)
src/breakpoints/index.ts
Outdated
noteTracker: INotebookTracker; | ||
previousCell: CodeCell; | ||
previousLineCount: number; | ||
cellsBreakpoints: { [id: string]: Breakpoints.IBreakpoint[] } = {}; |
There was a problem hiding this comment.
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?
src/breakpoints/index.ts
Outdated
}); | ||
} | ||
|
||
removeListner(cell: CodeCell) { |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
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. |
… afshin-debugger-ui
src/breakpoints/index.ts
Outdated
|
||
addBreakpoint(session: string, type: string, lineInfo: LineInfo) { | ||
const breakpoint: Breakpoints.IBreakpoint = { | ||
line: lineInfo.line, |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
src/breakpoints/index.ts
Outdated
this.breakpoints = []; | ||
} else { | ||
const breakpoint = { ...this.breakpoints[0] }; | ||
var breakpoints: Breakpoints.IBreakpoint[] = []; |
There was a problem hiding this comment.
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:
var breakpoints: Breakpoints.IBreakpoint[] = []; | |
let breakpoints: Breakpoints.IBreakpoint[] = []; |
@@ -153,7 +220,10 @@ const tracker: JupyterFrontEndPlugin<IDebugger> = { | |||
} | |||
|
|||
const widget = new MainAreaWidget({ | |||
content: new Debugger({ connector: state, id }) | |||
content: new Debugger({ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
I propose we merge this and iterate on it so that @jtpio and I can work off this branch. |
There was a problem hiding this 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.
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. |
@@ -52,6 +52,7 @@ | |||
"@phosphor/coreutils": "^1.3.1", | |||
"@phosphor/disposable": "^1.2.0", | |||
"@phosphor/widgets": "^1.8.0", | |||
"@types/codemirror": "0.0.76", |
There was a problem hiding this comment.
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