Open redactedscribe opened 1 year ago
If you work around the failing file creation using the variable transform provided above, here is some of the duplication (as described in #1215) which can occur. I think the positions of the $
-references worsen the problem. A simplified example:
This template...
---
foam_template:
filepath: "$FOAM_DATE_YEAR-$FOAM_DATE_MONTH-$FOAM_DATE_DATE $FOAM_TITLE.md"
title: $1
---
# $FOAM_DATE_YEAR-$FOAM_DATE_MONTH-$FOAM_DATE_DATE ${1:$FOAM_TITLE}
Some text.
$1
...with title "My daily note" becomes the note:
---
title: My daily note daily note
---
# 2023-04-25 ${1:My daily note2023-04-25 ${1:-04-25 My daily note daily note
Some text.
My daily note daily note
As you can see, duplication happens even without invalid characters.
partially fixed in #1232
Describe the bug
See title.
Small Reproducible Example
No response
Steps to Reproduce the Bug or Issue
$FOAM_TITLE
as part of.foam_template.filepath
's value.Invalid "Characters"
Expected behavior
Automatically strip invalid characters from the title and use that as the valid file name (as already happens when
$FOAM_TITLE
is outside of.foam_template.filepath
). Of course, mentions of$FOAM_TITLE
elsewhere should retain all the submitted characters.Screenshots or Videos
No response
Operating System Version
Windows 11
Visual Studio Code Version
VSCodium 1.77.3
Additional context
This can be worked around by using
filepath: "${FOAM_TITLE/[\/?*\"<>|:\\]/_/g}.md"
to replace each of Windows' invalid characters with an underscore. This only works around the failure to create the file, however, if you now provide a title with or without an invalid character, another related bug is encountered at this point (duplication of text), see #1215.Foam should probably handle these invalid characters instead of the user having to use VS Code variable transforms such as above.