From 1edcf1bcff1cdc6b22c646105c19631bec6dbc00 Mon Sep 17 00:00:00 2001 From: PathGao <42336971+PathGao@users.noreply.github.com> Date: Wed, 2 Sep 2026 08:39:07 +0800 Subject: [PATCH] fix(outline): a click on the outline in split view moves the editor too (#744) The outline's jump handed the source line to the editor only under isEditing. Split view entered from reading mode is isSplit alone, so the preview scrolled and the editor beside it stayed put. One derived flag, hasEditorPane, now answers "is there an editor on screen" for the jump and for the three places that already spelled out isEditing || isSplit. --- src/lib/MarkdownViewer.svelte | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/lib/MarkdownViewer.svelte b/src/lib/MarkdownViewer.svelte index b5a324f3..c843b714 100644 --- a/src/lib/MarkdownViewer.svelte +++ b/src/lib/MarkdownViewer.svelte @@ -361,6 +361,14 @@ import { createDocumentSession, type LoadMarkdownOptions } from './sessions/docu let isEditing = $derived(activeTab?.isEditing ?? false); let rawContent = $derived(activeTab?.rawContent ?? ''); let isSplit = $derived(activeTab?.isSplit ?? false); + /** + * Is there an editor on screen? The two flags are independent — split + * view is `isSplit` alone when entered from reading mode — so anything + * that hands the reader over to the editor has to ask both. The outline + * asked only `isEditing`, and a click on it in split view moved the + * preview but not the editor beside it (#744). + */ + let hasEditorPane = $derived(isEditing || isSplit); let frontMatterInfo = $derived(parseFrontMatter(rawContent)); // derived from tab manager @@ -429,7 +437,7 @@ import { createDocumentSession, type LoadMarkdownOptions } from './sessions/docu */ let editorToolbarHeight = $state(0); let paneTopChrome = $derived( - (isEditing || isSplit) && settings.showEditorToolbar ? editorToolbarHeight : 0, + hasEditorPane && settings.showEditorToolbar ? editorToolbarHeight : 0, ); let previewContentWidth = $derived(getPreviewContentWidth(settings.previewMaxWidth, settings.previewFullWidth)); let isOverhanging = $derived( @@ -3963,8 +3971,8 @@ import { createDocumentSession, type LoadMarkdownOptions } from './sessions/docu class:toc-resizing={isTocResizing} style="--toc-width: {settings.tocWidth}px; --pane-top-chrome: {paneTopChrome}px;"> -
- {#if isEditing || isSplit} +
+ {#if hasEditorPane} {#if settings.showEditorToolbar}
- {#if isSplit || isEditing} + {#if hasEditorPane}
{t('dragAndDrop.embed', settings.language)}