mblode / mblode/vscode-twig-language

Tracking: PrettyDiff formatter bugs (whitespace, indentation, JS-in-Twig)

Open
#66 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

formatter
Dominant language
JavaScript
Stars
45
Forks
7
PR merge metrics
No merged PRs in 30d

Description

This is a tracking issue for the family of formatting bugs in v1 that all stem from the underlying PrettyDiff 3 engine, which is no longer actively maintained.

These bugs share a root cause and are hard to fix at the extension level because the formatting logic lives in PrettyDiff. Grouping them here so they're easy to find.

Known formatter issues:

  • #17 Auto indent not working
  • #31 Twig block shorthand syntax indentation
  • #39 Whitespace-control tags ({%- / -%}) not handled by formatter
  • #41 Indented block comments pushed out to infinity
  • #44 JavaScript in Twig mangled
  • #47 Spacing in variables / tags not normalised ({{foo}} -> {{ foo }})
  • #48 Block inside an HTML tag formatted incorrectly
  • #49 Infinite space added before a variable inside JS
  • #52 JavaScript inside <script> de-indented
  • #57 href attribute sticks to the previous word inside list items
  • #61 Closing brackets not auto-inserted inside inline HTML tags
  • #64 Nested control structures lose indentation

Workarounds reported by users:

  • Disable the formatter and format manually.
  • Use prettier-plugin-twig-melody with a Twig-specific Prettier config for serious formatting needs.

If you're hitting a formatting bug, please add a comment here with a minimal before/after snippet rather than opening a new issue. Contributions toward replacing or patching the formatter are very welcome.

Thanks for your patience and for using the extension.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the linked PrettyDiff 3 project and the referenced formatting issues. Reproduce one listed case with a minimal before/after snippet, then assess whether the contribution should patch PrettyDiff or replace the formatter; done means the selected formatter problems are addressed.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.