-
-
Notifications
You must be signed in to change notification settings - Fork 35
Description
Feature request: It would be nice if Tomlyn could keep the ordering of nodes from the input, or if it could decouple comments from nodes if there's blank lines separating them.
Problem leading me here:
I have a TOML file for configuration purposes and I'm using JSON schema for validation as per the current only stable option. This means that my TOML starts with a comment on line 1, column 1. This also means that the comment is tacked onto the first node found after, and it cannot be written back in the same place unless that node happens to be the alphabetical first node.
Small example, using 2 newlines for demonstrative purposes (I tried a dozen in my local file before realizing it's a Tomlyn limitation):
#:schema ./config.schema.json
[db.postgres]
key = "val"
valid = true
[some.node.child]
foo = "bar"
[db.maria]
key = "otherval"
valid = falseThis works, parses fine, no complaints. Until you try to write back a changed config. which gets reordered automagically into:
[db.maria]
key = "otherval"
valid = false
#:schema ./config.schema.json
[db.postgres]
key = "val"
valid = true
[some.node.child]
foo = "bar"Adding in a buffer comment doesn't impact this either - there's two comments and a blank line in between them tacked onto [db.postrgres].