فهرست منبع

Deleting cells should select the next cell

Steven Silvester 8 سال پیش
والد
کامیت
989ba63a3a
2فایلهای تغییر یافته به همراه6 افزوده شده و 6 حذف شده
  1. 4 4
      src/notebook/notebook/actions.ts
  2. 2 2
      test/src/notebook/notebook/actions.spec.ts

+ 4 - 4
src/notebook/notebook/actions.ts

@@ -165,7 +165,7 @@ namespace NotebookActions {
    * @param widget - The target notebook widget.
    *
    * #### Notes
-   * The cell before the first selected cell will be activated.
+   * The cell after the last selected cell will be activated.
    * It will add a code cell if all cells are deleted.
    * This action can be undone.
    */
@@ -184,12 +184,12 @@ namespace NotebookActions {
     for (let i = 0; i < widget.childCount(); i++) {
       let child = widget.childAt(i);
       if (widget.isSelected(child)) {
-        if (index === -1) {
-          index = i - 1;
-        }
+        index = i;
         toDelete.push(cells.get(i));
       }
     }
+    // We want to select the cell *after* the last selected.
+    index -= toDelete.length - 1;
 
     // Delete the cells as one undo event.
     cells.beginCompoundOperation();

+ 2 - 2
test/src/notebook/notebook/actions.spec.ts

@@ -240,12 +240,12 @@ describe('notebook/notebook/actions', () => {
         expect(widget.mode).to.be('command');
       });
 
-      it('should activate the cell before the first selected cell', () => {
+      it('should activate the cell after the last selected cell', () => {
         widget.activeCellIndex = 4;
         let prev = widget.childAt(2);
         widget.select(prev);
         NotebookActions.deleteCells(widget);
-        expect(widget.activeCellIndex).to.be(1);
+        expect(widget.activeCellIndex).to.be(3);
       });
 
       it('should add a code cell if all cells are deleted', () => {