Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid characters for $FOAM_TITLE variable cause its value to be partially duplicated #1215

Open
redactedscribe opened this issue Apr 25, 2023 · 2 comments

Comments

@redactedscribe
Copy link

redactedscribe commented Apr 25, 2023

Describe the bug

If $FOAM_TITLE exists in a template and a new note is created from it, providing a title with invalid characters, e.g. Invalid "Characters", will cause the variable to be expanded into Invalid "Characters" "Characters".

Small Reproducible Example

No response

Steps to Reproduce the Bug or Issue

  1. Use $FOAM_TITLE in a Foam template.
  2. Create note from template.
  3. Title using invalid NTFS file system characters: Invalid "Characters"
  4. Note creation succeeds, but each occurrence of $FOAM_TITLE within the document has the duplicated text issue.

Expected behavior

No duplication. Invalid "Characters" -> Invalid "Characters".

Screenshots or Videos

No response

Operating System Version

Windows 11

Visual Studio Code Version

VSCodium 1.77.3

Additional context

For Windows' NTFS, these basic characters aren't allowed /?*"<>|:\ in file names.

Edit: I've linked some other issues to this one. This and #1216 likely have a common cause but separating the two helped with understanding and explaining what I was seeing.

@redactedscribe
Copy link
Author

After some further investigation, and after some fixes in recent Foam versions, it looks like the issue is to do with referencing a FOAM variable using the same tabstop number ($x) more than once. Normal VS Code variables don't have this issue.

Template:

---
foam_template:
  name: "Daily Test"
title: "${1:$FOAM_TITLE}"
---

# $1

## Some header

The title is "$1".

With a title of "Title of my New Note", the template expands to:

---
title: "Title of my New Note of my New Note of my New Note"
---

# Title of my New Note of my New Note of my New Note

## Some header

The title is "Title of my New Note of my New Note of my New Note".

Once you increment or remove the second and last $1 tabstops, or simply remove :$FOAM_TITLE from the first, then the duplication stops.

@riccardoferretti
Copy link
Collaborator

Wow thanks for finding that. I don't plan to address it right away, but let's leave this open in case anyone else is experiencing the problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants