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?

0
1 comment
Hello,

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.
1

Please sign in to leave a comment.