From 0b5db1340c1ac848efbc1e916230e8a4a53cb164 Mon Sep 17 00:00:00 2001 From: Yuri Karamian Date: Tue, 24 Feb 2026 23:32:14 +0100 Subject: [PATCH] v1.1.8 - Fix unsaved content lost when switching notes --- package.json | 2 +- src-tauri/Cargo.lock | 2 +- src-tauri/Cargo.toml | 2 +- src-tauri/tauri.conf.json | 2 +- src/lib/components/Editor.svelte | 30 +++++++++++++++++++++++++++++ src/lib/components/InfoPanel.svelte | 1 + 6 files changed, 35 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 1400573..a03be9a 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "helixnotes", "private": true, "license": "AGPL-3.0-or-later", - "version": "1.1.7", + "version": "1.1.8", "type": "module", "scripts": { "dev": "vite dev", diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 6fd986e..a6f423a 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -1750,7 +1750,7 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "helixnotes" -version = "1.1.7" +version = "1.1.8" dependencies = [ "chrono", "dirs", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index def8ee9..b41c6b1 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "helixnotes" -version = "1.1.7" +version = "1.1.8" description = "Local markdown note-taking app" authors = ["HelixNotes"] license = "AGPL-3.0-or-later" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 87e589d..14b0ea3 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "../node_modules/@tauri-apps/cli/config.schema.json", "productName": "HelixNotes", - "version": "1.1.7", + "version": "1.1.8", "identifier": "com.helixnotes.app", "build": { "frontendDist": "../build", diff --git a/src/lib/components/Editor.svelte b/src/lib/components/Editor.svelte index 5e0ee14..02fbb1e 100644 --- a/src/lib/components/Editor.svelte +++ b/src/lib/components/Editor.svelte @@ -1200,6 +1200,21 @@ } export function loadNote(path: string, content: string) { + // Flush any unsaved changes for the CURRENT note before loading the new one + if ($editorDirty && $activeNote && $activeNotePath && $activeNotePath !== path) { + try { + const body = $sourceMode + ? restoreTitleH1(sourceContent) + : editorToMarkdown(); + const trimmed = body.replace(/^#.*\n?/, '').trim(); + if (trimmed || !$activeNote.content || $activeNote.content.trim().length <= 10) { + saveNote($activeNotePath, $activeNote.meta, body); + } + } catch (e) { + console.error('Pre-switch save failed:', e); + } + $editorDirty = false; + } loadedPath = path; lastSourceMode = $sourceMode; isLoadingNote = true; @@ -1997,6 +2012,21 @@ }); function destroyEditor() { + // Flush unsaved changes before destroying + if ($editorDirty && $activeNote && $activeNotePath && editor) { + try { + const body = $sourceMode + ? restoreTitleH1(sourceContent) + : editorToMarkdown(); + const trimmed = body.replace(/^#.*\n?/, '').trim(); + if (trimmed || !$activeNote.content || $activeNote.content.trim().length <= 10) { + saveNote($activeNotePath, $activeNote.meta, body); + } + } catch (e) { + console.error('Destroy-save failed:', e); + } + $editorDirty = false; + } if (editor) { editor.destroy(); editor = null; diff --git a/src/lib/components/InfoPanel.svelte b/src/lib/components/InfoPanel.svelte index 665009b..7346414 100644 --- a/src/lib/components/InfoPanel.svelte +++ b/src/lib/components/InfoPanel.svelte @@ -127,6 +127,7 @@
Go backAlt+
Go forwardAlt+
Toggle source mode{modKey}+Shift+M
+
Open note in new window{modKey}+Shift+W
Exit focus modeEsc

Editor Commands