diff --git a/src/vs/workbench/contrib/notebook/browser/media/notebook.css b/src/vs/workbench/contrib/notebook/browser/media/notebook.css index 4ed5411e1b86e176106c6cd7efa734e3f9df3177..92c2562b6572908a7fffe1c36eaf3fc94ede401d 100644 --- a/src/vs/workbench/contrib/notebook/browser/media/notebook.css +++ b/src/vs/workbench/contrib/notebook/browser/media/notebook.css @@ -464,12 +464,6 @@ cursor: pointer; } -.monaco-workbench .notebookOverlay .monaco-list .monaco-list-row:hover .cell-focus-indicator, -.monaco-workbench .notebookOverlay .monaco-list .monaco-list-row.cell-output-hover .cell-focus-indicator, -.monaco-workbench .notebookOverlay .monaco-list .monaco-list-row.focused .cell-focus-indicator { - opacity: 1; -} - .monaco-workbench .notebookOverlay .monaco-list-row .cell-editor-part:before { z-index: 20; content: ""; diff --git a/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts b/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts index 45a1efd95aadc95f99ad6f88f1eac3a2e72e5f5f..df4e7d2e45d5fb4a881a31fe4aadceece8d2553b 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts @@ -1200,7 +1200,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor return null; } - const newIdx = index + 1; + const newIdx = index + 2; // This is the adjustment for the index before the cell has been "removed" from its original index return this._moveCellToIndex(index, newIdx); } @@ -1231,10 +1231,6 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor const relativeToIndex = this._notebookViewModel!.getCellIndex(relativeToCell); let newIdx = direction === 'above' ? relativeToIndex : relativeToIndex + 1; - if (originalIdx < newIdx) { - newIdx--; - } - return this._moveCellToIndex(originalIdx, newIdx); } @@ -1247,7 +1243,17 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor return this._moveCellToIndex(originalIdx, index); } + /** + * @param index The current index of the cell + * @param newIdx The desired index, in an index scheme for the state of the tree before the current cell has been "removed". + * @example to move the cell from index 0 down one spot, call with (0, 2) + */ private async _moveCellToIndex(index: number, newIdx: number): Promise { + if (index < newIdx) { + // The cell is moving "down", it will free up one index spot and consume a new one + newIdx--; + } + if (index === newIdx) { return null; } diff --git a/src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts b/src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts index 1cf2b75d684c636aecfbb802a49faed9fae87213..d0b8d958d687d4b81265c8930486ebd28903f6d9 100644 --- a/src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts +++ b/src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts @@ -622,9 +622,9 @@ export class CellDragAndDropController extends Disposable { const dropDirection = this.getDropInsertDirection(event); const insertionIndicatorAbsolutePos = dropDirection === 'above' ? event.cellTop : event.cellTop + event.cellHeight; - const insertionIndicatorTop = insertionIndicatorAbsolutePos - this.list.scrollTop; + const insertionIndicatorTop = insertionIndicatorAbsolutePos - this.list.scrollTop + BOTTOM_CELL_TOOLBAR_HEIGHT / 2; if (insertionIndicatorTop >= 0) { - this.listInsertionIndicator.style.top = `${insertionIndicatorAbsolutePos - this.list.scrollTop}px`; + this.listInsertionIndicator.style.top = `${insertionIndicatorTop}px`; this.setInsertIndicatorVisibility(true); } else { this.setInsertIndicatorVisibility(false); @@ -637,6 +637,11 @@ export class CellDragAndDropController extends Disposable { private onCellDrop(event: CellDragEvent): void { const draggedCell = this.currentDraggedCell!; + + if (this.isScrolling || this.currentDraggedCell === event.draggedOverCell) { + return; + } + let draggedCells: ICellViewModel[] = [draggedCell]; if (draggedCell.cellKind === CellKind.Markdown) { @@ -655,7 +660,7 @@ export class CellDragAndDropController extends Disposable { const dropDirection = this.getDropInsertDirection(event); const insertionIndicatorAbsolutePos = dropDirection === 'above' ? event.cellTop : event.cellTop + event.cellHeight; - const insertionIndicatorTop = insertionIndicatorAbsolutePos - this.list.scrollTop; + const insertionIndicatorTop = insertionIndicatorAbsolutePos - this.list.scrollTop + BOTTOM_CELL_TOOLBAR_HEIGHT / 2; const editorHeight = this.notebookEditor.getDomNode().getBoundingClientRect().height; if (insertionIndicatorTop < 0 || insertionIndicatorTop > editorHeight) { // Ignore drop, insertion point is off-screen