Fix of automatic calendar note imports #267
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The problem
The plugin is unable to create the notes following the template and folder set in settings under
Default template
andDefault folder
whenever theAuto create Event Notes Marker
is set to any non-empty value and the description does not contain full, 3-part:directory-marker-template
notation. Instead, depending on what's provided it creates a note in root directory or/and without using template.Example
Calendar setup
I've prepared four events in my calendar:
Obisidian setup
Empty vault with
Templates
,Templater
andGoogle Calendar
plugins installed.Plugin setup
Expected result
events
directory usingdefault.md
template.directory
directory usingdefault.md
template.events
directory usingtemplate.md
template.directory
directory usingtemplate.md
template.Expectations were set by documentation of Auto create EventNotes
Actual result
root
directory without using template.directory
directory without using template.root
directory usingtemplate.md
template.directory
directory usingtemplate.md
template.The cause
Whenever the regex
:([^:]*-)?obsidian-?([^:]*)?:
matches a string that does not contains anything that can be put into first or second capturing group the value passed to thecreateNoteFromEvent
is set toundefined
.When undefined is passed to the
createNoteFromEvent
weird things happen - the note does not know what template to use or where it belongs. All other 6 calls to thecreateNoteFromEvent
in project use syntax that uses values from config likecreateNoteFromEvent(event, this.settings.defaultFolder, this.settings.defaultTemplate)
or very close to this notation.The solution
Fallback values from settings should be used whenever the parsed value is undefined.
The proof
Given exactly the same setup test yielded:
events
directory usingdefault.md
template.directory
directory usingdefault.md
template.events
directory usingtemplate.md
template.directory
directory usingtemplate.md
template.