Skip to content

Commit

Permalink
Fix dragging cells down
Browse files Browse the repository at this point in the history
Fix #96427
  • Loading branch information
roblourens committed Apr 28, 2020
1 parent 9b91e5b commit fb754da
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/vs/workbench/contrib/notebook/browser/notebookEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -830,11 +830,19 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
const originalIdx = this.notebookViewModel!.getCellIndex(cell);
const relativeToIndex = this.notebookViewModel!.getCellIndex(relativeToCell);

const newIdx = direction === 'above' ? relativeToIndex : relativeToIndex + 1;
let newIdx = direction === 'above' ? relativeToIndex : relativeToIndex + 1;
if (originalIdx < newIdx) {
newIdx--;
}

return this.moveCellToIndex(originalIdx, newIdx);
}

private async moveCellToIndex(index: number, newIdx: number): Promise<boolean> {
if (index === newIdx) {
return false;
}

if (!this.notebookViewModel!.moveCellToIdx(index, newIdx, true)) {
throw new Error('Notebook Editor move cell, index out of range');
}
Expand Down

0 comments on commit fb754da

Please sign in to comment.