@@ -1153,22 +1153,25 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
1153
1153
const endTime = Date . now ( ) + deadline . timeRemaining ( ) ;
1154
1154
1155
1155
const execute = ( ) => {
1156
- this . _backgroundMarkdownRenderRunning = false ;
1157
- if ( this . _isDisposed ) {
1158
- return ;
1159
- }
1156
+ try {
1157
+ this . _backgroundMarkdownRenderRunning = true ;
1158
+ if ( this . _isDisposed ) {
1159
+ return ;
1160
+ }
1160
1161
1161
- if ( ! this . viewModel ) {
1162
- return ;
1163
- }
1162
+ if ( ! this . viewModel ) {
1163
+ return ;
1164
+ }
1164
1165
1165
- const firstMarkupCell = this . viewModel . viewCells . find ( cell => cell . cellKind === CellKind . Markup && ! this . _webview ?. markupPreviewMapping . has ( cell . id ) ) as MarkupCellViewModel | undefined ;
1166
- if ( ! firstMarkupCell ) {
1167
- return ;
1168
- }
1166
+ const firstMarkupCell = this . viewModel . viewCells . find ( cell => cell . cellKind === CellKind . Markup && ! this . _webview ?. markupPreviewMapping . has ( cell . id ) && ! this . cellIsHidden ( cell ) ) as MarkupCellViewModel | undefined ;
1167
+ if ( ! firstMarkupCell ) {
1168
+ return ;
1169
+ }
1169
1170
1170
- this . _backgroundMarkdownRenderRunning = true ;
1171
- this . createMarkupPreview ( firstMarkupCell ) ;
1171
+ this . createMarkupPreview ( firstMarkupCell ) ;
1172
+ } finally {
1173
+ this . _backgroundMarkdownRenderRunning = false ;
1174
+ }
1172
1175
1173
1176
if ( Date . now ( ) < endTime ) {
1174
1177
setTimeout0 ( execute ) ;
@@ -2564,10 +2567,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
2564
2567
return ;
2565
2568
}
2566
2569
2567
- const modelIndex = this . viewModel . getCellIndex ( cell ) ;
2568
- const foldedRanges = this . viewModel . getHiddenRanges ( ) ;
2569
- const isVisible = ! foldedRanges . some ( range => modelIndex >= range . start && modelIndex < range . end ) ;
2570
- if ( ! isVisible ) {
2570
+ if ( this . cellIsHidden ( cell ) ) {
2571
2571
return ;
2572
2572
}
2573
2573
@@ -2585,6 +2585,12 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
2585
2585
} ) ;
2586
2586
}
2587
2587
2588
+ private cellIsHidden ( cell : ICellViewModel ) : boolean {
2589
+ const modelIndex = this . viewModel ! . getCellIndex ( cell ) ;
2590
+ const foldedRanges = this . viewModel ! . getHiddenRanges ( ) ;
2591
+ return foldedRanges . some ( range => modelIndex >= range . start && modelIndex <= range . end ) ;
2592
+ }
2593
+
2588
2594
async unhideMarkupPreviews ( cells : readonly MarkupCellViewModel [ ] ) {
2589
2595
if ( ! this . _webview ) {
2590
2596
return ;
0 commit comments