From 5a7bbd0269a172e09a9880a9de916d433e7f94e5 Mon Sep 17 00:00:00 2001 From: thecodexapp <113909005+uthvah@users.noreply.github.com> Date: Thu, 18 Sep 2025 23:13:15 +0100 Subject: [PATCH] Update main.js --- main.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/main.js b/main.js index 4b5e5c3..c5f9740 100644 --- a/main.js +++ b/main.js @@ -74,21 +74,15 @@ module.exports = class SyncEmbedPlugin extends Plugin { return; } - // --- SECTION LOGIC --- if (section) { let fullContent = await this.app.vault.read(file); const sectionContent = this.extractSection(fullContent, section); view.editor.setValue(sectionContent); - // --- THE FIX --- - // Disconnect the view from the file to prevent Obsidian's native - // auto-save from overwriting the entire note with just the section. view.file = null; - // --------------- const debouncedSave = debounce(async () => { const newSectionText = view.editor.getValue(); - // We must re-read the file right before saving to get the latest version. const currentFullContent = await this.app.vault.read(file); const newFullContent = this.replaceSection(currentFullContent, section, newSectionText); @@ -97,7 +91,6 @@ module.exports = class SyncEmbedPlugin extends Plugin { } }, 500, true); - // Register the save function on editor changes for this specific view component.registerEvent(this.app.workspace.on('editor-change', (editor) => { if (editor === view.editor) { debouncedSave();