Skip to content

Commit

Permalink
fix: use find instead of foldersMatching
Browse files Browse the repository at this point in the history
This is to avoid inadvertant fuzzy matches.
  • Loading branch information
ksalzke committed Oct 17, 2021
1 parent a4a9740 commit 64c0461
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Resources/templateLibrary.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global Alert PlugIn Version Preferences foldersMatching Form flattenedSections Folder Project duplicateTasks duplicateSections Task Tag Calendar deleteObject library flattenedFolders flattenedTags Formatter */
/* global Alert PlugIn Version Preferences Form flattenedSections Folder Project duplicateTasks duplicateSections Task Tag Calendar deleteObject library flattenedFolders flattenedTags Formatter */
(() => {
const templateLibrary = new PlugIn.Library(new Version('1.0'))

Expand Down Expand Up @@ -39,8 +39,10 @@
const preferences = new Preferences('com.KaitlinSalzke.Templates')

// find folder from string, if there is a destination
if (template.note.match(/\$FOLDER=(.*?)$/m) !== null) {
return foldersMatching(template.note.match(/\$FOLDER=(.*?)$/m)[1])[0]
const match = template.note.match(/\$FOLDER=(.*?)$/m)
const destFolder = (match === null) ? undefined : flattenedFolders.find(folder => folder.name === match[1])
if (destFolder !== undefined) {
return destFolder
} else {
// otherwise, show form to user to select
const destinationForm = new Form()
Expand Down

0 comments on commit 64c0461

Please sign in to comment.