Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this change do?
Implements optional table order and trivia preservation.
I have included table order preservation in this PR because fine-grained trivia preservation doesn't make much sense if large blocks of the document get reordered regardless. I can split table order preservation into a separate PR if you'd like.
This is my first time writing CPP (although I've written plenty of C in the past), so just let me know if there's anything I've got wrong. I think I'm starting to understand move semantics and stuff like that, but I made quite a few mistakes earlier on (some of which led to crashes), and I probably haven't caught all of them.
Is it related to an exisiting bug report or feature request?
Addresses #28 (and extends its goals to include all trivia)
Todo
-Dordered_tables=true
)collect_trivia
parameter available on all top-level parsing functions)format_flags::preserve_source_trivia
)0x15
should remain hexadecimal after round-tripping)'foo'
shouldn't become '"foo"' after round-tripping)Trivia inference
Trivia inference for inserted toml values won't be perfect of course, but should at least be able to respect when e.g. a document only has single quotes, or always uses 4 space indentation. I'm thinking perhaps trivia preferences could be 'dragged' down through the document. So e.g. a new array element will use the style of the previous array element (if any). We could possibly start the 'drag' operation below the new element before wrapping around to the top in order to syntax that comes later in the document if there aren't any examples before the inserted syntax. This approach sounds slow describing it like that, but we'd probably be able to cache the dragged preferences at each node and only update them when inserting new elements.
Pre-merge checklist
origin/master
(if necessary)