File tree Expand file tree Collapse file tree
src/vs/workbench/contrib/notebook/browser Expand file tree Collapse file tree Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments