From ea180a77e691c47ebda7adf0ebc491610c2c34d8 Mon Sep 17 00:00:00 2001 From: PathGao <42336971+PathGao@users.noreply.github.com> Date: Sat, 25 Jul 2026 04:53:37 +0900 Subject: [PATCH] fix: pause fold measurement while preview is hidden --- scripts/foldLayout.test.ts | 6 ++++++ src/lib/MarkdownViewer.svelte | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/foldLayout.test.ts b/scripts/foldLayout.test.ts index 2bad3d3..0a66505 100644 --- a/scripts/foldLayout.test.ts +++ b/scripts/foldLayout.test.ts @@ -25,3 +25,9 @@ test('preview lifecycle starts and cleans up fold observation', () => { assert.match(viewer, /observeFoldLayout\((?:markdownBody|body)\)/); assert.match(viewer, /stopObservingFoldLayout\?\.\(\)/); }); + +test('fold measurement pauses while the preview pane is hidden by edit mode', () => { + const viewer = readFileSync('src/lib/MarkdownViewer.svelte', 'utf8'); + + assert.match(viewer, /if \(!html \|\| !body \|\| \(isEditing && !isSplit\)\) return;/); +}); diff --git a/src/lib/MarkdownViewer.svelte b/src/lib/MarkdownViewer.svelte index df723ec..c0176ce 100644 --- a/src/lib/MarkdownViewer.svelte +++ b/src/lib/MarkdownViewer.svelte @@ -1016,7 +1016,7 @@ import { t } from './utils/i18n.js'; $effect(() => { const html = sanitizedHtml; const body = markdownBody; - if (!html || !body) return; + if (!html || !body || (isEditing && !isSplit)) return; let cancelled = false; tick().then(() => {