Skip to content

Commit fb754da

Browse files
committed
Fix dragging cells down
Fix microsoft#96427
1 parent 9b91e5b commit fb754da

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/vs/workbench/contrib/notebook/browser/notebookEditor.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,11 +830,19 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
830830
const originalIdx = this.notebookViewModel!.getCellIndex(cell);
831831
const relativeToIndex = this.notebookViewModel!.getCellIndex(relativeToCell);
832832

833-
const newIdx = direction === 'above' ? relativeToIndex : relativeToIndex + 1;
833+
let newIdx = direction === 'above' ? relativeToIndex : relativeToIndex + 1;
834+
if (originalIdx < newIdx) {
835+
newIdx--;
836+
}
837+
834838
return this.moveCellToIndex(originalIdx, newIdx);
835839
}
836840

837841
private async moveCellToIndex(index: number, newIdx: number): Promise<boolean> {
842+
if (index === newIdx) {
843+
return false;
844+
}
845+
838846
if (!this.notebookViewModel!.moveCellToIdx(index, newIdx, true)) {
839847
throw new Error('Notebook Editor move cell, index out of range');
840848
}

0 commit comments

Comments
 (0)