5
5
6
6
import { DeferredPromise } from '../../../../base/common/async.js' ;
7
7
import { Disposable , IDisposable , toDisposable } from '../../../../base/common/lifecycle.js' ;
8
- import { ICellViewModel , CellLayoutContext } from './notebookBrowser.js' ;
8
+ import { ICellViewModel } from './notebookBrowser.js' ;
9
9
import { NotebookEditorWidget } from './notebookEditorWidget.js' ;
10
10
import { INotebookCellList } from './view/notebookRenderingCommon.js' ;
11
11
import * as DOM from '../../../../base/browser/dom.js' ;
@@ -14,6 +14,7 @@ import { INotebookLoggingService } from '../common/notebookLoggingService.js';
14
14
export class NotebookCellLayoutManager extends Disposable {
15
15
private _pendingLayouts : WeakMap < ICellViewModel , IDisposable > | null = new WeakMap < ICellViewModel , IDisposable > ( ) ;
16
16
private _layoutDisposables : Set < IDisposable > = new Set < IDisposable > ( ) ;
17
+ private readonly _layoutStack : string [ ] = [ ] ;
17
18
private _isDisposed = false ;
18
19
constructor (
19
20
private notebookWidget : NotebookEditorWidget ,
@@ -23,8 +24,16 @@ export class NotebookCellLayoutManager extends Disposable {
23
24
super ( ) ;
24
25
}
25
26
26
- async layoutNotebookCell ( cell : ICellViewModel , height : number , context ?: CellLayoutContext ) : Promise < void > {
27
- this . loggingService . debug ( 'cell layout' , `cell:${ cell . handle } , height:${ height } ` ) ;
27
+ private checkStackDepth ( ) {
28
+ if ( this . _layoutStack . length > 30 ) {
29
+ const layoutTrace = this . _layoutStack . join ( ' -> ' ) ;
30
+ throw new Error ( 'NotebookCellLayoutManager: layout stack is too deep: ' + layoutTrace ) ;
31
+ }
32
+ }
33
+
34
+ async layoutNotebookCell ( cell : ICellViewModel , height : number ) : Promise < void > {
35
+ const layoutTag = `cell:${ cell . handle } , height:${ height } ` ;
36
+ this . loggingService . debug ( 'cell layout' , layoutTag ) ;
28
37
const viewIndex = this . _list . getViewIndex ( cell ) ;
29
38
if ( viewIndex === undefined ) {
30
39
// the cell is hidden
@@ -40,6 +49,7 @@ export class NotebookCellLayoutManager extends Disposable {
40
49
const pendingLayout = this . _pendingLayouts ?. get ( cell ) ;
41
50
this . _pendingLayouts ?. delete ( cell ) ;
42
51
52
+ this . _layoutStack . push ( layoutTag ) ;
43
53
try {
44
54
if ( this . _isDisposed ) {
45
55
return ;
@@ -59,6 +69,7 @@ export class NotebookCellLayoutManager extends Disposable {
59
69
return ;
60
70
}
61
71
72
+ this . checkStackDepth ( ) ;
62
73
63
74
if ( ! this . notebookWidget . hasEditorFocus ( ) ) {
64
75
// Do not scroll inactive notebook
@@ -76,6 +87,7 @@ export class NotebookCellLayoutManager extends Disposable {
76
87
77
88
this . _list . updateElementHeight2 ( cell , height ) ;
78
89
} finally {
90
+ this . _layoutStack . pop ( ) ;
79
91
deferred . complete ( undefined ) ;
80
92
if ( pendingLayout ) {
81
93
pendingLayout . dispose ( ) ;
0 commit comments