Repository navigation
Preserve hash brace padding and pad auto-closed Twig delimiters - #125
Merged
Merged
Conversation
Fixes #124: the formatter stripped spaces inside hash literals such as `with { "content": "my tooltip" }`. Brace pairs now keep a single space when the author padded either side, and stay tight otherwise. Fixes #123: auto-closing {{, {% and {# left the cursor as {{| }}. The extension now inserts the missing space once the cursor settles, giving {{ | }}. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NCo2qCP2ZkpV2b8hrk3UBS
This was referenced Sep 24, 2026
Merged
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NCo2qCP2ZkpV2b8hrk3UBS
mblode
marked this pull request as ready for review
September 24, 2026 20:23
mblode
pushed a commit
to mblode/vscode-twig-language
that referenced
this pull request
Sep 24, 2026
Synchronized from mblode/vscode-twig-language-2#125 with scripts/sync-core.mjs. Ports the fixes for vscode-twig-language-2#124 (formatter stripped spaces inside hash literals) and #123 (cursor left at {{| }} after auto-close). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NCo2qCP2ZkpV2b8hrk3UBS
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_1d97c009-da1b-471e-9150-61f8ca7842b4) |
mblode
pushed a commit
to mblode/vscode-pretty-formatter
that referenced
this pull request
Sep 24, 2026
Synchronized from mblode/vscode-twig-language-2#125 with scripts/sync-core.mjs. Ports the formatter fix for vscode-twig-language-2#124 (spaces inside hash literals such as with { "content": "x" } were removed). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NCo2qCP2ZkpV2b8hrk3UBS
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.
Fixes #124, fixes #123.
#124 — space inside
withhashes removedformatTwigunconditionally tightened{/}, so{% include 'tooltip.twig' with { "content": "my tooltip" } %}became{"content": "my tooltip"}. Brace pairs are now matched and keep a single space when the author padded either side; unpadded hashes stay tight, empty{ }becomes{}. Both styles are idempotent.#123 — cursor after auto-closing
{{,{%,{#The auto-closing pair
" }}"left the cursor as{{| }}. The extension now detects that auto-close edit (VS Code emits it as"{ }","% %","# #"), waits for the typing command to move the cursor to the expected offset, then inserts a space without an undo stop. Result:{{ | }}. Multi-cursor supported; undo/redo edits are ignored.Other changes
.twig-core.jsonhashes refreshed viascripts/sync-core.mjs(format.js and extension.js are shared core).vscode-twig-languageandvscode-pretty-formatterstill need a sync to pick these fixes up.test/provider.test.jsvscode mock stubs the two new event APIs.Testing
npm test: 318 pass, including new Space insidewithobject gets incorrectly removed #124 cases.xvfb-run npm run test:extensionon VS Code 1.85.2 (4 runs) and stable: new integration test types{{/{%/{#thenxand asserts{{ x }}etc.🤖 Generated with Claude Code
https://claude.ai/code/session_01NCo2qCP2ZkpV2b8hrk3UBS
Generated by Claude Code
Note
Low Risk
Localized formatter spacing rules and optional document edits on Twig auto-close; no security or persistence changes, with new unit and integration tests.
Overview
Release 0.12.2 fixes two Twig editing/formatting UX issues.
The formatter no longer strips intentional spaces inside hash braces: padded
with { "content": "x" }stays padded, tight{"content":"x"}stays tight, and empty{ }still collapses to{}. Brace pairs are tracked so padding is preserved when either side had whitespace in the source.The extension adds listeners on document change and selection change so that after VS Code auto-closes
{{,{%, or{#, a space is inserted inside the opening delimiter (without a separate undo stop), leaving the cursor in{{ | }}instead of{{| }}. Shared core hashes in.twig-core.jsonand the bundledextension/output are updated accordingly.Regression coverage includes formatter cases for #124 and VS Code integration tests that type delimiters and assert padded auto-close behavior; provider tests stub the new workspace/window subscriptions.
Reviewed by Cursor Bugbot for commit 7880673. Bugbot is set up for automated code reviews on this repo. Configure here.