From c1d33e97ce59c79620b5e578109e555801219376 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 10 Dec 2025 02:28:51 +0000 Subject: [PATCH 1/3] Initial plan From 263eb454eab266704146ff263e05f47793283b64 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 10 Dec 2025 02:49:15 +0000 Subject: [PATCH 2/3] Fix folded markdown cell preview showing on notebook reopen - Added check in viewUpdatePreview() to hide preview if cell is in a folded region - Call viewUpdate() when foldingStateChanged event fires to update preview visibility - This ensures previews are hidden when folding state is restored after notebook opens Co-authored-by: DonJayamanne <1948812+DonJayamanne@users.noreply.github.com> --- .../browser/view/cellParts/markupCell.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/vs/workbench/contrib/notebook/browser/view/cellParts/markupCell.ts b/src/vs/workbench/contrib/notebook/browser/view/cellParts/markupCell.ts index c1b90d72e8ad6..b89cb9c063923 100644 --- a/src/vs/workbench/contrib/notebook/browser/view/cellParts/markupCell.ts +++ b/src/vs/workbench/contrib/notebook/browser/view/cellParts/markupCell.ts @@ -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) { @@ -412,6 +416,20 @@ 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 + 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); } From fce6cf295b0d9774ff0bb125fc5ae9906e705983 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 10 Dec 2025 02:54:10 +0000 Subject: [PATCH 3/3] Add clarifying comment about hidden range logic Co-authored-by: DonJayamanne <1948812+DonJayamanne@users.noreply.github.com> --- .../contrib/notebook/browser/view/cellParts/markupCell.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/vs/workbench/contrib/notebook/browser/view/cellParts/markupCell.ts b/src/vs/workbench/contrib/notebook/browser/view/cellParts/markupCell.ts index b89cb9c063923..8b068a1d13fdb 100644 --- a/src/vs/workbench/contrib/notebook/browser/view/cellParts/markupCell.ts +++ b/src/vs/workbench/contrib/notebook/browser/view/cellParts/markupCell.ts @@ -418,6 +418,7 @@ 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);