Ver Fonte

resolve issue with set breakpoints after dispose notebook

Borys Palka há 5 anos atrás
pai
commit
af4417885f
3 ficheiros alterados com 15 adições e 9 exclusões
  1. 5 1
      src/handlers/cell.ts
  2. 8 7
      src/handlers/notebook.ts
  3. 2 1
      src/index.ts

+ 5 - 1
src/handlers/cell.ts

@@ -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);

+ 8 - 7
src/handlers/notebook.ts

@@ -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({
@@ -46,10 +47,6 @@ export class NotebookHandler implements IDisposable {
     }
     this.isDisposed = true;
     this.cellManager.dispose();
-    this.notebookTracker.activeCellChanged.disconnect(
-      this.onActiveCellChanged,
-      this
-    );
     Signal.clearData(this);
   }
 
@@ -57,9 +54,11 @@ export class NotebookHandler implements IDisposable {
     notebookTracker: NotebookTracker,
     codeCell: CodeCell
   ) {
-    requestAnimationFrame(() => {
-      this.cellManager.activeCell = codeCell;
-    });
+    if (notebookTracker.currentWidget.id === this.id) {
+      requestAnimationFrame(() => {
+        this.cellManager.activeCell = codeCell;
+      });
+    }
   }
 
   private notebookTracker: INotebookTracker;
@@ -67,11 +66,13 @@ export class NotebookHandler implements IDisposable {
   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;
   }
 }

+ 2 - 1
src/index.ts

@@ -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(() => {