Skip to content

Scope hanging bracket content in plan output#100

Open
michaelblyons wants to merge 3 commits intoSublimeText:masterfrom
michaelblyons:plan/hanging-bracket
Open

Scope hanging bracket content in plan output#100
michaelblyons wants to merge 3 commits intoSublimeText:masterfrom
michaelblyons:plan/hanging-bracket

Conversation

@michaelblyons
Copy link
Contributor

@michaelblyons michaelblyons commented Jan 3, 2026

It bugs me that the plan output from #51 has hanging bits that don't have, e.g. a - at BOL below:

    ] -> null

This PR looks for { and [ at EOL and pairs them to their closing brackets without meta scopes. If opening brackets need detection mid-line, this task is probably impossible.

Before After
Screenshot_20260121_125321 Screenshot_20260103_170850

Comment on lines +94 to +102
closing-bracket:
- match: ^(?=\s*\])
pop: 1
- include: diffs

closing-brace:
- match: ^\s*\}
pop: 1
- include: diffs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These contexts match more than just what they are named and represent the state the parser is in at the time. Thus, they would be more appropriately named "bracket-body" or "inside-brackets" or similar. (I do not remember which naming convention is currently used in this syntax definition.)

Comment on lines +104 to +108
pop-eol-bracket-deleted:
- match: \[$\n?
set: closing-bracket-deleted
- match: \{$\n?
set: closing-brace-deleted
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These contexts do not pop at eol and calling them that would be misleading. Instead, how about bracket-at-eol-deleted, using the naming schema that non-plural versions of a context imply a pop?

scope: keyword.operator.assignment.terraform
- match: \(known after apply\)$
scope: comment.block.terraform
- match: \bnull$
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this EOL anchor really necessary? Seems overly restrictive.

@michaelblyons michaelblyons requested a review from FichteFoll March 2, 2026 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants