|
@@ -1,7 +1,7 @@
|
|
// Copyright (c) Jupyter Development Team.
|
|
// Copyright (c) Jupyter Development Team.
|
|
// Distributed under the terms of the Modified BSD License.
|
|
// Distributed under the terms of the Modified BSD License.
|
|
|
|
|
|
-import { CodeCell, ICellModel } from '@jupyterlab/cells';
|
|
|
|
|
|
+import { Cell, CodeCell, ICellModel } from '@jupyterlab/cells';
|
|
|
|
|
|
import { CodeMirrorEditor } from '@jupyterlab/codemirror';
|
|
import { CodeMirrorEditor } from '@jupyterlab/codemirror';
|
|
|
|
|
|
@@ -15,6 +15,8 @@ import { Editor } from 'codemirror';
|
|
|
|
|
|
import { Breakpoints, SessionTypes } from '../breakpoints';
|
|
import { Breakpoints, SessionTypes } from '../breakpoints';
|
|
|
|
|
|
|
|
+import { Callstack } from '../callstack';
|
|
|
|
+
|
|
import { Debugger } from '../debugger';
|
|
import { Debugger } from '../debugger';
|
|
|
|
|
|
import { IDebugger } from '../tokens';
|
|
import { IDebugger } from '../tokens';
|
|
@@ -43,11 +45,10 @@ export class CellManager implements IDisposable {
|
|
|
|
|
|
this._debuggerModel.callstackModel.currentFrameChanged.connect(
|
|
this._debuggerModel.callstackModel.currentFrameChanged.connect(
|
|
(_, frame) => {
|
|
(_, frame) => {
|
|
- this.cleanupHighlight();
|
|
|
|
|
|
+ CellManager.cleanupHighlight(this.activeCell);
|
|
if (!frame) {
|
|
if (!frame) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- this.showCurrentLine(frame.line);
|
|
|
|
}
|
|
}
|
|
);
|
|
);
|
|
|
|
|
|
@@ -74,26 +75,6 @@ export class CellManager implements IDisposable {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private showCurrentLine(lineNumber: number) {
|
|
|
|
- if (!this.activeCell) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- const editor = this.activeCell.editor as CodeMirrorEditor;
|
|
|
|
- this.cleanupHighlight();
|
|
|
|
- editor.editor.addLineClass(lineNumber - 1, 'wrap', LINE_HIGHLIGHT_CLASS);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // TODO: call when the debugger stops
|
|
|
|
- private cleanupHighlight() {
|
|
|
|
- if (!this.activeCell || this.activeCell.isDisposed) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- const editor = this.activeCell.editor as CodeMirrorEditor;
|
|
|
|
- editor.doc.eachLine(line => {
|
|
|
|
- editor.editor.removeLineClass(line, 'wrap', LINE_HIGHLIGHT_CLASS);
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
dispose(): void {
|
|
dispose(): void {
|
|
if (this.isDisposed) {
|
|
if (this.isDisposed) {
|
|
return;
|
|
return;
|
|
@@ -105,7 +86,7 @@ export class CellManager implements IDisposable {
|
|
this._cellMonitor.dispose();
|
|
this._cellMonitor.dispose();
|
|
}
|
|
}
|
|
this.removeListener(this.activeCell);
|
|
this.removeListener(this.activeCell);
|
|
- this.cleanupHighlight();
|
|
|
|
|
|
+ CellManager.cleanupHighlight(this.activeCell);
|
|
Signal.clearData(this);
|
|
Signal.clearData(this);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -291,6 +272,31 @@ export namespace CellManager {
|
|
activeCell?: CodeCell;
|
|
activeCell?: CodeCell;
|
|
type: SessionTypes;
|
|
type: SessionTypes;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Highlight the current line of the frame in the given cell.
|
|
|
|
+ * @param cell The cell to highlight.
|
|
|
|
+ * @param frame The frame with the current line number.
|
|
|
|
+ */
|
|
|
|
+ export function showCurrentLine(cell: Cell, frame: Callstack.IFrame) {
|
|
|
|
+ const editor = cell.editor as CodeMirrorEditor;
|
|
|
|
+ cleanupHighlight(cell);
|
|
|
|
+ editor.editor.addLineClass(frame.line - 1, 'wrap', LINE_HIGHLIGHT_CLASS);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Remove all line highlighting indicators for the given cell.
|
|
|
|
+ * @param cell The cell to cleanup.
|
|
|
|
+ */
|
|
|
|
+ export function cleanupHighlight(cell: Cell) {
|
|
|
|
+ if (!cell || cell.isDisposed) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ const editor = cell.editor as CodeMirrorEditor;
|
|
|
|
+ editor.doc.eachLine(line => {
|
|
|
|
+ editor.editor.removeLineClass(line, 'wrap', LINE_HIGHLIGHT_CLASS);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
export interface ILineInfo {
|
|
export interface ILineInfo {
|