Bug: Adding existing value to text-property formats property as list
Solanaar opened this issue · 2 comments
Issue:
When you add a value to a property of type text and that is the only value, it formats it as if the property type is list, leading to a type missmatch warning.
Reproduction:
- Create a new note
- add a text property (e.g. location)
- add a value (e.g. earth)
if done correctly, it should look like this:
location: earth
- right click on the folder and run the "Add props to folder's notes" command
- put in the property name and the value, type should stay as "Text" and submit
Result:
The property will be reformatted to a list, while the property type will stay as text, which results in a type missmatch exception. Example:
location:
- earth
Workaround:
Option A: Before adding the value, change the property-type to list.
Option B: Before adding the value, first remove the property from all notes in that folder.
Both workarounds have their shortcomings. Option A will add additional lines to the frontmatter, making it less readable and potentially leading to conflicts if the property is used in other folders, while option B could potentially lead to loss of data, if some notes in that folder contain a different value for that property.
Use case/Relevancy:
When adding a property with only one value to all notes in a folder, while some already have that property and value. For example when you have a TTRPG vault with a folder named "people" and a property named "type", that would have values like "people, location, item, etc.", usually every note would only have one value, so a list wouldn't be necessary.
I hope this hasn't been reported yet and I could provide a clear report.
Sounds like you have the "Overwrite existing text" setting disabled. When that's the case, any new text properties will automatically be combined and appended to a list. When Overwrite is enabled, then the text property will remain as text.
I hadn't foreseen the possibility of the exact same value being added and merged, leading to a single text value being read as a list. I should be able to create a check for whether the values are the same.
This should be fixed in the 1.1.2 release.