marcusolsson / obsidian-projects

Plain text project planning in Obsidian
Apache License 2.0
1.39k stars 55 forks source link

Overwriting unchanged fields #184

Open usernotnull opened 1 year ago

usernotnull commented 1 year ago

What happened?

When changing any value (such as 'Published') with this library, ALL YAML is overwritten.

What did you expect to happen?

Unchanged fields should remain unchanged.

How can we reproduce it (as minimally and precisely as possible)?

add a note such as below and change the boolean from the table view:

summary: "This is an example of John's Test string"
published: false

The summary field is overwritten when toggling published checkbox, with the quotations removed.

Anything else we need to know?

No response

Plugin version

1.2.1

Obsidian version

1.0.3

OS

Windows

marcusolsson commented 1 year ago

YAML supports quoted and unquoted strings, and many Obsidian users prefer not to quote properties in their front matter. For these reasons I don't consider stripping quotes a bug. However, if you get a parsing error as a result, that is something I'd like to look into.

That being said, I agree that users should be able to configure whether string values should be quoted or not. Let me know if that would work for you!

usernotnull commented 1 year ago

I agree, having it as an option has the most flexibility. I think the quotation option in the settings should only apply when the value is null and being overwritten by the plugin. Other fields which are not over written should not be affected.

Users should rely on linters for consistent formatting so ideally this lib should preserve the original values of unchanged fields (ie title should not change when I'm checking published field checkbox with this plugin).

marcusolsson commented 1 year ago

💯

The initial implementation was rather naïve and just overwrote all the properties. I've recently updated the data layer to leave all unset properties as is, but I haven't updated the views to make use of it yet.

I feel like this issue describes ~3 different issues. Would you mind splitting the issue so that we can track them separately? 🙏

usernotnull commented 1 year ago

Done

marcusolsson commented 1 year ago

Thank you! 🙏

FeralFlora commented 1 year ago

This behavior is also messing up aliases and tag fields by inserting "null" and formatting these as multi-line, when the user might prefer a single-line array.

Edit: It seems I was mistaken and another plugin is causing the multi-line change, but I think Projects is adding the "null". Feel free to correct me. Second edit: It seems it was actually the Mindmap Nextgen plugin causing this behavior since their last update 12 hours ago, for some reason.

savvyslog commented 1 year ago

This behavior is breaking my combined use of this and the Obsidian Digital Garden plugins.

Namely, when I have a metadata key like dg-publish = true it's automatically changed to dg-publish = "true", regardless of what change I actually made on the board or table views. This then effectively unpublishes the note (re: second plugin), without any notification from either plugin.

My "Quote Strings" setting is set as "If needed", so I wouldn't think that should be an issue.

I will open an issue for that plugin as well, requesting it accept "true" as an equivalent value to true, but it'd be nice if this issue were resolved anyway.