瀏覽代碼

Backport PR #11766: Preserve breakpoint gutter when cells are moved. (#11832)

Co-authored-by: Frédéric Collonval <fcollonval@users.noreply.github.com>
MeeseeksMachine 3 年之前
父節點
當前提交
2d32e88a4f
共有 2 個文件被更改,包括 24 次插入3 次删除
  1. 7 0
      packages/debugger/src/handlers/editor.ts
  2. 17 3
      packages/debugger/src/handlers/notebook.ts

+ 7 - 0
packages/debugger/src/handlers/editor.ts

@@ -89,6 +89,13 @@ export class EditorHandler implements IDisposable {
     Signal.clearData(this);
   }
 
+  /**
+   * Refresh the breakpoints display
+   */
+  refreshBreakpoints(): void {
+    this._addBreakpointsToEditor();
+  }
+
   /**
    * Setup the editor.
    */

+ 17 - 3
packages/debugger/src/handlers/notebook.ts

@@ -1,9 +1,14 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import { Cell, CodeCell } from '@jupyterlab/cells';
+import { Cell, CodeCell, ICellModel } from '@jupyterlab/cells';
 
-import { IObservableMap, ObservableMap } from '@jupyterlab/observables';
+import {
+  IObservableList,
+  IObservableMap,
+  IObservableUndoableList,
+  ObservableMap
+} from '@jupyterlab/observables';
 
 import { Notebook, NotebookPanel } from '@jupyterlab/notebook';
 
@@ -57,10 +62,19 @@ export class NotebookHandler implements IDisposable {
   /**
    * Handle a notebook cells changed event.
    */
-  private _onCellsChanged(): void {
+  private _onCellsChanged(
+    cells?: IObservableUndoableList<ICellModel>,
+    changes?: IObservableList.IChangedArgs<ICellModel>
+  ): void {
     this._notebookPanel.content.widgets.forEach(cell =>
       this._addEditorHandler(cell)
     );
+
+    if (changes?.type === 'move') {
+      for (const cell of changes.newValues) {
+        this._cellMap.get(cell.id)?.refreshBreakpoints();
+      }
+    }
   }
 
   /**