Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions new-note-namer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion new-note-namer/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -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. <br><br> Specially useful when the 'Allow note file name to be different to note title. \n No more cumbersome renaming :)"
}
16 changes: 13 additions & 3 deletions new-note-namer/new-note-namer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Loading