fix #188851, fix dom reading, fix rendering python comments (#188882)

This commit is contained in:
Michael Lively
2023-07-26 08:35:41 -07:00
committed by GitHub
parent 71bf483f13
commit b4da76b08c
@@ -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);