New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix background markdown rendering issues #153871
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1153,22 +1153,25 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD | |
const endTime = Date.now() + deadline.timeRemaining(); | ||
|
||
const execute = () => { | ||
this._backgroundMarkdownRenderRunning = false; | ||
if (this._isDisposed) { | ||
return; | ||
} | ||
try { | ||
this._backgroundMarkdownRenderRunning = true; | ||
if (this._isDisposed) { | ||
return; | ||
} | ||
|
||
if (!this.viewModel) { | ||
return; | ||
} | ||
if (!this.viewModel) { | ||
return; | ||
} | ||
|
||
const firstMarkupCell = this.viewModel.viewCells.find(cell => cell.cellKind === CellKind.Markup && !this._webview?.markupPreviewMapping.has(cell.id)) as MarkupCellViewModel | undefined; | ||
if (!firstMarkupCell) { | ||
return; | ||
} | ||
const firstMarkupCell = this.viewModel.viewCells.find(cell => cell.cellKind === CellKind.Markup && !this._webview?.markupPreviewMapping.has(cell.id) && !this.cellIsHidden(cell)) as MarkupCellViewModel | undefined; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here, don't take the cell if it is hidden. |
||
if (!firstMarkupCell) { | ||
return; | ||
} | ||
|
||
this._backgroundMarkdownRenderRunning = true; | ||
this.createMarkupPreview(firstMarkupCell); | ||
this.createMarkupPreview(firstMarkupCell); | ||
} finally { | ||
this._backgroundMarkdownRenderRunning = false; | ||
} | ||
|
||
if (Date.now() < endTime) { | ||
setTimeout0(execute); | ||
|
@@ -2564,10 +2567,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD | |
return; | ||
} | ||
|
||
const modelIndex = this.viewModel.getCellIndex(cell); | ||
const foldedRanges = this.viewModel.getHiddenRanges(); | ||
const isVisible = !foldedRanges.some(range => modelIndex >= range.start && modelIndex < range.end); | ||
if (!isVisible) { | ||
if (this.cellIsHidden(cell)) { | ||
return; | ||
} | ||
|
||
|
@@ -2585,6 +2585,12 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD | |
}); | ||
} | ||
|
||
private cellIsHidden(cell: ICellViewModel): boolean { | ||
const modelIndex = this.viewModel!.getCellIndex(cell); | ||
const foldedRanges = this.viewModel!.getHiddenRanges(); | ||
return foldedRanges.some(range => modelIndex >= range.start && modelIndex <= range.end); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed from < to <=, that seems correct here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what other issue might have been triggered by this though. |
||
} | ||
|
||
async unhideMarkupPreviews(cells: readonly MarkupCellViewModel[]) { | ||
if (!this._webview) { | ||
return; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixing this flag so that
_backgroundMarkdownRendering
doesn't bail on the second time through.