diff --git a/src/lib/components/Editor.svelte b/src/lib/components/Editor.svelte index ab9a2bf..8bcc27d 100644 --- a/src/lib/components/Editor.svelte +++ b/src/lib/components/Editor.svelte @@ -2660,6 +2660,11 @@ } } + // The markdown body the editor would currently save; used to ignore the file-watcher echo of our own save. + export function getCurrentBody(): string { + return $sourceMode ? restoreTitleH1(sourceContent) : editorToMarkdown(); + } + // ── Tag editing (active note) ── function toggleTagMenu(e: MouseEvent) { if (tagMenu) { tagMenu = null; return; } diff --git a/src/lib/components/NoteWindow.svelte b/src/lib/components/NoteWindow.svelte index 0dee877..4634cee 100644 --- a/src/lib/components/NoteWindow.svelte +++ b/src/lib/components/NoteWindow.svelte @@ -103,8 +103,11 @@ if (!$editorDirty) { try { const content = await readNote(notePath); - $activeNote = content; - editor?.loadNote(notePath, content.content); + // Ignore the file-watcher echo of our own save; only reload genuine external edits. + if (content.content.trim() !== (editor?.getCurrentBody() ?? '').trim()) { + $activeNote = content; + editor?.loadNote(notePath, content.content); + } } catch (_) {} } }