From f8ebb88d3d09da12ba752e2e00420a9828a0fe16 Mon Sep 17 00:00:00 2001 From: luginf Date: Mon, 28 Sep 2026 14:56:25 +0200 Subject: [PATCH] new-note-namer: fix rename prompt firing on existing notes (#300) note.fileCreated == "Invalid Date" was used to detect a brand-new note, but it also reads "Invalid Date" the first time a pre-existing, not-yet-indexed note file is edited and saved -- it marks "new DB row", not "new file on disk". This made the script wrongly prompt for a file name on existing notes. Replace it with a one-shot flag set in handleNewNoteHeadlineHook, which only fires for genuine new-note creation, immediately before handleNoteTextFileNameHook. Bump to 0.0.5 and add a CHANGELOG entry. Co-Authored-By: Claude Sonnet 5 --- new-note-namer/CHANGELOG.md | 4 ++++ new-note-namer/info.json | 2 +- new-note-namer/new-note-namer.qml | 16 +++++++++++++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/new-note-namer/CHANGELOG.md b/new-note-namer/CHANGELOG.md index 24185e6..031c6f2 100644 --- a/new-note-namer/CHANGELOG.md +++ b/new-note-namer/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.0.5 - 2026-09-28 + +- Fixed the file-name prompt wrongly firing when an existing, not-yet-indexed note is edited and saved for the first time (#300). The rename logic now gates on a flag set only by the genuine new-note creation hook, instead of `note.fileCreated`. + ## 0.0.4 - 2026-05-26 - Added independent title and filename dialog settings, with search terms used directly when dialogs are disabled. diff --git a/new-note-namer/info.json b/new-note-namer/info.json index 5e74d1c..737d149 100644 --- a/new-note-namer/info.json +++ b/new-note-namer/info.json @@ -4,7 +4,7 @@ "script": "new-note-namer.qml", "authors": ["@diegovskytl", "@Mystechry", "@luginf"], "platforms": ["linux", "macos", "windows"], - "version": "0.0.4", + "version": "0.0.5", "minAppVersion": "17.06.2", "description": "Enables a dialog window (or two, or even none) so the user can choose the note title and file name at the moment of creation, or simply use the search term for the filename and title of the note with custom formattings.

Specially useful when the 'Allow note file name to be different to note title. \n No more cumbersome renaming :)" } diff --git a/new-note-namer/new-note-namer.qml b/new-note-namer/new-note-namer.qml index aa0005c..e3c3f0f 100644 --- a/new-note-namer/new-note-namer.qml +++ b/new-note-namer/new-note-namer.qml @@ -11,6 +11,7 @@ QtObject { property bool extraDialogForFileName property string headingStyle property string _searchTerm: "" + property bool _isNewNote: false property string customHeadingOpen property string customHeadingClose property bool underlineHeading // deprecated — kept so existing stored settings still load @@ -66,6 +67,11 @@ QtObject { function handleNewNoteHeadlineHook(headline) { // 'headline' is a plain string (the search term or default text), not a Note object. + // Only this hook fires for a genuine new-note creation, right before + // handleNoteTextFileNameHook — used below to gate the rename/prompt logic + // instead of note.fileCreated, which also reads "Invalid Date" the first + // time a pre-existing, not-yet-indexed note file is edited and saved. + _isNewNote = true; // Strip QOwnNotes search filter prefixes (e.g. "n:" for name-only search). _searchTerm = headline.replace(/^n:/i, ""); var name; @@ -113,11 +119,15 @@ QtObject { return firstLine.slice(2); // ATX: remove "# " } function handleNoteTextFileNameHook(note) { - // right when a note is created, the fileCreated property value is 'Invalid Date' - // this blocks the hook from further changing the note file name if the note title is changed - if (note.fileCreated != "Invalid Date") { + // Only act right after handleNewNoteHeadlineHook fired for THIS note + // creation (see hook order note above). note.fileCreated == "Invalid Date" + // was used previously, but it also reads "Invalid Date" the first time a + // pre-existing, not-yet-indexed note file is edited and saved — which made + // this hook wrongly fire (and prompt) on existing notes (issue #300). + if (!_isNewNote) { return ""; } + _isNewNote = false; // consume the flag: only the note just created gets renamed // Default file name: search term if available, otherwise derived from the title. var defaultName = _searchTerm !== "" ? _searchTerm : extractTitle(note.noteText);