Twig formatter issue
I have a specific problem while formatting some code in Twig.
I have a structure like this after the formatting has been applied:
{{ component('MyComponent', { foo: 'bar', key: [ [ { key: { key: value } }, { key: value } ] ]}) }}
But it should be, and I would like it to be like this:
{{ component('MyComponent', { foo: 'bar', key: [ [ { key: { key: value } }, { key: value } ] ]}) }}
I also noticed that if I compact it like the following, the problem disappears.
{{ component('MyComponent', { foo: 'bar', key: [ [{ key: { key: value } }, { key: value }] ]}) }}
I tried to search a bit, but my problem is specific enough I didn't find it elsewhere.
Is this a bug the formatter has?
请先登录再写评论。
This does look like a bug in how the Twig formatter handles nested object literals (mappings). Therefore, I've filed it here:
https://youtrack.jetbrains.com/issue/WI-85065
As of now, you can stick with the workaround you've mentioned. Thank you for bringing this to my attention.
This looks like a formatter bug. Since the indentation is only wrong for this specific nested structure and works when the code is rearranged, it's likely an issue with the formatter's parser. Make sure you're using the latest version, and if the problem remains, report it with a minimal reproducible example so the maintainers can investigate.