@@ -213,10 +213,10 @@ export class NotebookStickyScroll extends Disposable {
213
213
}
214
214
215
215
// 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 ) {
220
220
// this is the end of the section
221
221
// store the bottom scroll position of this cell
222
222
sectionBottom = this . notebookCellList . getCellViewScrollBottom ( cell ) ;
@@ -299,9 +299,9 @@ export class NotebookStickyScroll extends Disposable {
299
299
300
300
// if we are here, the cell is a code cell.
301
301
// 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 ) {
305
305
// this is the end of the section
306
306
// store the bottom scroll position of this cell
307
307
sectionBottom = this . notebookCellList . getCellViewScrollBottom ( cell ) ;
@@ -376,8 +376,8 @@ export class NotebookStickyScroll extends Disposable {
376
376
}
377
377
378
378
private updateDisplay ( ) {
379
- const hasChildren = this . domNode . hasChildNodes ( ) ;
380
- if ( ! hasChildren ) {
379
+ const hasSticky = this . currentStickyLines . size > 0 ;
380
+ if ( ! hasSticky ) {
381
381
this . domNode . style . display = 'none' ;
382
382
} else {
383
383
this . domNode . style . display = 'block' ;
@@ -400,6 +400,11 @@ export class NotebookStickyScroll extends Disposable {
400
400
401
401
const elementsToRender = [ ] ;
402
402
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
+ }
403
408
const lineToRender = this . createStickyElement ( currentEntry , partial ) ;
404
409
newMap . set ( currentEntry , lineToRender ) ;
405
410
elementsToRender . unshift ( lineToRender ) ;
0 commit comments