Skip to content

Commit b4da76b

Browse files
authored
fix microsoft#188851, fix dom reading, fix rendering python comments (microsoft#188882)
1 parent 71bf483 commit b4da76b

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/vs/workbench/contrib/notebook/browser/viewParts/notebookEditorStickyScroll.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,10 @@ export class NotebookStickyScroll extends Disposable {
213213
}
214214

215215
// if we are here, the cell is a code cell.
216-
// check next cell, if markdown, that means this is the end of the section
217-
const nextCell = this.notebookEditor.cellAt(i + 1);
218-
if (nextCell) {
219-
if (nextCell.cellKind === CellKind.Markup) {
216+
// check next visible cell, if markdown, that means this is the end of the section
217+
const nextVisibleCell = this.notebookEditor.cellAt(i + 1);
218+
if (nextVisibleCell && i + 1 < visibleRange.end) {
219+
if (nextVisibleCell.cellKind === CellKind.Markup) {
220220
// this is the end of the section
221221
// store the bottom scroll position of this cell
222222
sectionBottom = this.notebookCellList.getCellViewScrollBottom(cell);
@@ -299,9 +299,9 @@ export class NotebookStickyScroll extends Disposable {
299299

300300
// if we are here, the cell is a code cell.
301301
// check next cell, if markdown, that means this is the end of the section
302-
const nextCell = this.notebookEditor.cellAt(i + 1);
303-
if (nextCell) {
304-
if (nextCell.cellKind === CellKind.Markup) {
302+
const nextVisibleCell = this.notebookEditor.cellAt(i + 1);
303+
if (nextVisibleCell && i + 1 < visibleRange.end) {
304+
if (nextVisibleCell.cellKind === CellKind.Markup) {
305305
// this is the end of the section
306306
// store the bottom scroll position of this cell
307307
sectionBottom = this.notebookCellList.getCellViewScrollBottom(cell);
@@ -376,8 +376,8 @@ export class NotebookStickyScroll extends Disposable {
376376
}
377377

378378
private updateDisplay() {
379-
const hasChildren = this.domNode.hasChildNodes();
380-
if (!hasChildren) {
379+
const hasSticky = this.currentStickyLines.size > 0;
380+
if (!hasSticky) {
381381
this.domNode.style.display = 'none';
382382
} else {
383383
this.domNode.style.display = 'block';
@@ -400,6 +400,11 @@ export class NotebookStickyScroll extends Disposable {
400400

401401
const elementsToRender = [];
402402
while (currentEntry) {
403+
if (currentEntry.level === 7) {
404+
// level 7 represents a comment in python, which we don't want to render
405+
currentEntry = currentEntry.parent;
406+
continue;
407+
}
403408
const lineToRender = this.createStickyElement(currentEntry, partial);
404409
newMap.set(currentEntry, lineToRender);
405410
elementsToRender.unshift(lineToRender);

0 commit comments

Comments
 (0)