Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ export class MarkupCell extends Disposable {
this.foldingState = foldingState;
this.layoutFoldingIndicator();
}

// When folding state changes, we need to update the view to show/hide the preview
// This is important when restoring folding state on notebook open
this.viewUpdate();
}

if (e.cellIsHoveredChanged) {
Expand Down Expand Up @@ -412,6 +416,21 @@ export class MarkupCell extends Disposable {
}
}

// Check if the cell is inside a folded region - if so, hide the preview instead of creating it
// This handles the case where the preview was created before folding state was restored
// Note: Hidden ranges start at the first hidden cell (not the fold header), so >= is correct
const viewModel = this.notebookEditor.getViewModel();
if (viewModel) {
const modelIndex = viewModel.getCellIndex(this.viewCell);
const foldedRanges = viewModel.getHiddenRanges();
const isHidden = foldedRanges.some(range => modelIndex >= range.start && modelIndex <= range.end);

if (isHidden) {
this.notebookEditor.hideMarkupPreviews([this.viewCell]);
return;
}
}

this.notebookEditor.createMarkupPreview(this.viewCell);
}

Expand Down