Skip to content

Commit 9864932

Browse files
luginfclaude
authored andcommitted
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 <noreply@anthropic.com>
1 parent 730ee4c commit 9864932

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

‎new-note-namer/CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.0.5 - 2026-09-28
4+
5+
- 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`.
6+
37
## 0.0.4 - 2026-05-26
48

59
- Added independent title and filename dialog settings, with search terms used directly when dialogs are disabled.

‎new-note-namer/info.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"script": "new-note-namer.qml",
55
"authors": ["@diegovskytl", "@Mystechry", "@luginf"],
66
"platforms": ["linux", "macos", "windows"],
7-
"version": "0.0.4",
7+
"version": "0.0.5",
88
"minAppVersion": "17.06.2",
99
"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. <br><br> Specially useful when the 'Allow note file name to be different to note title. \n No more cumbersome renaming :)"
1010
}

‎new-note-namer/new-note-namer.qml‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ QtObject {
1111
property bool extraDialogForFileName
1212
property string headingStyle
1313
property string _searchTerm: ""
14+
property bool _isNewNote: false
1415
property string customHeadingOpen
1516
property string customHeadingClose
1617
property bool underlineHeading // deprecated — kept so existing stored settings still load
@@ -66,6 +67,11 @@ QtObject {
6667

6768
function handleNewNoteHeadlineHook(headline) {
6869
// 'headline' is a plain string (the search term or default text), not a Note object.
70+
// Only this hook fires for a genuine new-note creation, right before
71+
// handleNoteTextFileNameHook — used below to gate the rename/prompt logic
72+
// instead of note.fileCreated, which also reads "Invalid Date" the first
73+
// time a pre-existing, not-yet-indexed note file is edited and saved.
74+
_isNewNote = true;
6975
// Strip QOwnNotes search filter prefixes (e.g. "n:" for name-only search).
7076
_searchTerm = headline.replace(/^n:/i, "");
7177
var name;
@@ -113,11 +119,15 @@ QtObject {
113119
return firstLine.slice(2); // ATX: remove "# "
114120
}
115121
function handleNoteTextFileNameHook(note) {
116-
// right when a note is created, the fileCreated property value is 'Invalid Date'
117-
// this blocks the hook from further changing the note file name if the note title is changed
118-
if (note.fileCreated != "Invalid Date") {
122+
// Only act right after handleNewNoteHeadlineHook fired for THIS note
123+
// creation (see hook order note above). note.fileCreated == "Invalid Date"
124+
// was used previously, but it also reads "Invalid Date" the first time a
125+
// pre-existing, not-yet-indexed note file is edited and saved — which made
126+
// this hook wrongly fire (and prompt) on existing notes (issue #300).
127+
if (!_isNewNote) {
119128
return "";
120129
}
130+
_isNewNote = false; // consume the flag: only the note just created gets renamed
121131

122132
// Default file name: search term if available, otherwise derived from the title.
123133
var defaultName = _searchTerm !== "" ? _searchTerm : extractTitle(note.noteText);

0 commit comments

Comments
 (0)