From b4da76b08c39f7fc125f99d4eb4cdce7ace0e20e Mon Sep 17 00:00:00 2001 From: Michael Lively Date: Wed, 26 Jul 2023 08:35:41 -0700 Subject: [PATCH] fix #188851, fix dom reading, fix rendering python comments (#188882) --- .../viewParts/notebookEditorStickyScroll.ts | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/vs/workbench/contrib/notebook/browser/viewParts/notebookEditorStickyScroll.ts b/src/vs/workbench/contrib/notebook/browser/viewParts/notebookEditorStickyScroll.ts index 1855cc0413f..c8eba1a66e4 100644 --- a/src/vs/workbench/contrib/notebook/browser/viewParts/notebookEditorStickyScroll.ts +++ b/src/vs/workbench/contrib/notebook/browser/viewParts/notebookEditorStickyScroll.ts @@ -213,10 +213,10 @@ export class NotebookStickyScroll extends Disposable { } // if we are here, the cell is a code cell. - // check next cell, if markdown, that means this is the end of the section - const nextCell = this.notebookEditor.cellAt(i + 1); - if (nextCell) { - if (nextCell.cellKind === CellKind.Markup) { + // check next visible cell, if markdown, that means this is the end of the section + const nextVisibleCell = this.notebookEditor.cellAt(i + 1); + if (nextVisibleCell && i + 1 < visibleRange.end) { + if (nextVisibleCell.cellKind === CellKind.Markup) { // this is the end of the section // store the bottom scroll position of this cell sectionBottom = this.notebookCellList.getCellViewScrollBottom(cell); @@ -299,9 +299,9 @@ export class NotebookStickyScroll extends Disposable { // if we are here, the cell is a code cell. // check next cell, if markdown, that means this is the end of the section - const nextCell = this.notebookEditor.cellAt(i + 1); - if (nextCell) { - if (nextCell.cellKind === CellKind.Markup) { + const nextVisibleCell = this.notebookEditor.cellAt(i + 1); + if (nextVisibleCell && i + 1 < visibleRange.end) { + if (nextVisibleCell.cellKind === CellKind.Markup) { // this is the end of the section // store the bottom scroll position of this cell sectionBottom = this.notebookCellList.getCellViewScrollBottom(cell); @@ -376,8 +376,8 @@ export class NotebookStickyScroll extends Disposable { } private updateDisplay() { - const hasChildren = this.domNode.hasChildNodes(); - if (!hasChildren) { + const hasSticky = this.currentStickyLines.size > 0; + if (!hasSticky) { this.domNode.style.display = 'none'; } else { this.domNode.style.display = 'block'; @@ -400,6 +400,11 @@ export class NotebookStickyScroll extends Disposable { const elementsToRender = []; while (currentEntry) { + if (currentEntry.level === 7) { + // level 7 represents a comment in python, which we don't want to render + currentEntry = currentEntry.parent; + continue; + } const lineToRender = this.createStickyElement(currentEntry, partial); newMap.set(currentEntry, lineToRender); elementsToRender.unshift(lineToRender);