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

Commit

Permalink
Merge pull request #163 from KsavinN/develop
Browse files Browse the repository at this point in the history
Resolve issues with Notebook Handler
  • Loading branch information
jtpio authored Nov 11, 2019
2 parents 9015b8c + 8e1ad3c commit f641270
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
11 changes: 9 additions & 2 deletions src/handlers/cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ export class CellManager implements IDisposable {
});

this.breakpointsModel.changed.connect(async () => {
if (!this.activeCell || this.activeCell.isDisposed) {
if (
!this.activeCell ||
!this.activeCell.isVisible ||
this.activeCell.isDisposed
) {
return;
}
this.addBreakpointsToEditor(this.activeCell);
Expand All @@ -69,7 +73,7 @@ export class CellManager implements IDisposable {

// TODO: call when the debugger stops
private cleanupHighlight() {
if (!this.activeCell) {
if (!this.activeCell || this.activeCell.isDisposed) {
return;
}
const editor = this.activeCell.editor as CodeMirrorEditor;
Expand Down Expand Up @@ -162,6 +166,9 @@ export class CellManager implements IDisposable {
}

protected removeListener(cell: CodeCell) {
if (cell.isDisposed) {
return;
}
const editor = cell.editor as CodeMirrorEditor;
editor.editor.off('gutterClick', this.onGutterClick);
}
Expand Down
15 changes: 10 additions & 5 deletions src/handlers/notebook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class NotebookHandler implements IDisposable {
this.debuggerModel = options.debuggerService.model;
this.debuggerService = options.debuggerService;
this.notebookTracker = options.tracker;
this.id = options.id;
this.breakpoints = this.debuggerModel.breakpointsModel;

this.cellManager = new CellManager({
Expand All @@ -46,30 +47,34 @@ export class NotebookHandler implements IDisposable {
}
this.isDisposed = true;
this.cellManager.dispose();
this.notebookTracker.activeCellChanged.disconnect(
this.onActiveCellChanged,
this
);
Signal.clearData(this);
}

protected onActiveCellChanged(
notebookTracker: NotebookTracker,
codeCell: CodeCell
) {
this.cellManager.activeCell = codeCell;
if (notebookTracker.currentWidget.id !== this.id) {
return;
}
// TODO: do we need this requestAnimationFrame?
requestAnimationFrame(() => {
this.cellManager.activeCell = codeCell;
});
}

private notebookTracker: INotebookTracker;
private debuggerModel: Debugger.Model;
private debuggerService: IDebugger;
private breakpoints: Breakpoints.Model;
private cellManager: CellManager;
private id: string;
}

export namespace NotebookHandler {
export interface IOptions {
debuggerService: IDebugger;
tracker: INotebookTracker;
id?: string;
}
}
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ class DebuggerHandler<H extends ConsoleHandler | NotebookHandler> {
if (debug.model && !this.handlers[widget.id]) {
const handler = new this.builder({
tracker: tracker,
debuggerService: debug
debuggerService: debug,
id: widget.id
});
this.handlers[widget.id] = handler;
widget.disposed.connect(() => {
Expand Down
4 changes: 3 additions & 1 deletion style/breakpoints.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
}

.jp-CodeCell.jp-mod-selected .CodeMirror-gutter-wrapper:hover::after,
.jp-Editor.jp-mod-focused .CodeMirror-gutter-wrapper:hover::after {
.jp-Editor.jp-mod-focused
.CodeMirror:not(.jp-mod-readOnly)
.CodeMirror-gutter-wrapper:hover::after {
opacity: 0.5;
}

0 comments on commit f641270

Please sign in to comment.