Fix: TOML table to avoid splitting brackets from key #4045
+24
−26
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.
I had discovered an issue where TOML table header parsing had undesired behaviour where table declarations like [table] and [[array]] were being split across multiple tokens, creating split spans when parsed. The bug was actually, for me, in refractor but refractor uses the same logic to parsing as prism so prism also should get a fix.
I have implemented a change in behaviour to toml header parsing in this PR which keeps the entire table header as a single token, you can see the change in the diff on the test output but basically [header] becomes [header] rather than "[", "header" ,"]" (and also made a simplification by removing insertkey in place of dottedkeyHowever, having thought about it a bit longer, I do recognise this is perhaps not an upgrade since no longer does this allow separate styling of the punctuation in the header compared to the key.So what I would propose is to copy the approach used in parsing ini files, where the whole thing becomes a nested structure
using this:
to produce this output:
I swapped to this approach that mirrors ini as, on reflection, it is clearly the best choice.