Enhancement: preserve front matter comments when modifying content via the Front Matter UI #659

Open
opened 2026-10-05 02:59:07 +02:00 by adam · 1 comment
Owner

Is your feature request related to a problem? Please describe.

I often add comments to front matter. For example

relatedPosts:
  - fxcf9e6db7765 # the post about x
  - c473788b6886 # the post about y

If I use the Front Matter UI to update content —for example by clicking the "now" button on a datetime field— those comments are deleted.

Describe the solution you'd like

Preserve comments when changes via the UI trigger rewriting the front matter. Change only what I explicitly changed.

Describe alternatives you've considered

Currently I git-add files before using the FrontMatter UI, then use the Front Matter UI, then check the un-cached diff and remove any changes I didn't ask for.

Additional context

I think this is distinct from

which appears to be about comments in the Front Matter config.

**Is your feature request related to a problem? Please describe.** I often add comments to front matter. For example ``` relatedPosts: - fxcf9e6db7765 # the post about x - c473788b6886 # the post about y ``` If I use the Front Matter UI to update content —for example by clicking the "now" button on a datetime field— those comments are deleted. **Describe the solution you'd like** Preserve comments when changes via the UI trigger rewriting the front matter. Change only what I explicitly changed. **Describe alternatives you've considered** Currently I git-add files before using the FrontMatter UI, then use the Front Matter UI, then check the un-cached diff and remove any changes I didn't ask for. **Additional context** I _think_ this is distinct from - #242 which appears to be about comments in the Front Matter config. <!-- github-sync-id:2447297995 -->
Author
Owner

Thanks, @olets, for opening this issue. Comments in YAML are tricky. I have yet to find a good YAML parser that can preserve those comments. The difficulty is in converting the YAML to JSON where all comments are lost, and then back to YAML where they need to be included again.

I'll try to see if there is any progress since the issue you referred to on this.

Thanks, @olets, for opening this issue. Comments in YAML are tricky. I have yet to find a good YAML parser that can preserve those comments. The difficulty is in converting the YAML to JSON where all comments are lost, and then back to YAML where they need to be included again. I'll try to see if there is any progress since the issue you referred to on this. <!-- github-comment-id:2268364518 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/vscode-front-matter#659