feat(parser): multi-line object/array literals with comments#794
Merged
Conversation
Object and array literals can now span multiple lines. In decorator comments each continuation line is prefixed with `#` (mirroring multi-line function calls); literals nested in item-value function calls use plain newlines. Inside either form, `#` starts a comment to end-of-line, so entries can be commented out or annotated. Continuation across a newline still requires the leading `#` in decorator context, so a missing `#` can never silently swallow following config items.
Contributor
|
The changes in this PR will be included in the next version bump.
|
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
varlock-website | 155f5e7 | Commit Preview URL Branch Preview URL |
Jun 16 2026, 11:50 PM |
commit: |
…ments
The TextMate grammar now recognizes object `{...}` and array `[...]`
literals (previously highlighted as plain strings), in both decorator and
item-value contexts, including multi-line forms. Inline `#` comments inside
multi-line literals and function calls (commented-out entries and trailing
notes) are now scoped as comments.
Adds item-value-context coverage (plain-newline continuation) for comments inside multi-line literals and function calls — commented-out entries and trailing post-comments — across arrays, objects, and fn-call args, matching the existing decorator-context coverage. Also tightens the TextMate grammar's literal continuation marker to a column-0 `#` so indented item-value comment lines are scoped as full comments instead of being split into a marker + unquoted string.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.


Follow-up to the object/array literals work: literals can now span multiple lines, so long key lists (e.g. a big
@import(..., pick=[...])) don't have to live on one line.What changed
#comments), each continuation line is prefixed with#.#starts a comment to end-of-line, so individual entries can be commented out (# # OLD_KEY,) or annotated (# KEY, # note).Safety
Continuation across a newline still requires the leading
#in decorator context, so a missing#can never silently swallow following config items — a malformed bracket falls back to a plain string and the lines below stay independent config items.Implementation
_valWs) and decorator-context (_decWs) rule sets, matching the existingFunctionArgs/DecoratorFunctionArgssplit, and taught both whitespace rules to skip#comments.bracket-literalrules (object/array, multi-line via begin/end, comment-aware) wired into every arg context;key-value-pairand the literal-scoped unquoted/numeric rules now terminate at}/]so closing brackets aren't swallowed.Tests
import pick=[...], comments/post-comments, trailing-comma handling, and the no-swallow safety property; plus an end-to-end@setValuesBulk pick=[...]test.grammar.test.txt(CI-checked) for single- and multi-line literals + inline comments, plus a new.env.literalssnapshot fixture.Docs updated in
env-spec/reference.