Indent spacing inconsistent when non PHP code like HTML is inside PHP file

I can't seem to figure out why the moment I have a mix of PHP and HTML inside a PHP file, my indent spacing randomly reverts back to 2 spaces regardless of setting. Is this a bug or am I missing something here? Everything is set to 4 spaces and under Code Style, I've tried playing around with the options "Detect and use existing file indents for editing" and "Enable EditorConfig support" but it doesn't seem to make any differences at all (I don't even use EditorConfig files so the second option probably doesn't apply).

I tend to copy paste blocks of code and sometimes, the pasted blocks show the correct 4 space indents and sometimes, everything gets reformatted to 2 spaces. Once I get the 2 spaces code, then every new indent becomes 2 spaces until I copy the entire file, empty it out then make an arbitrary change to my PHP CodeStyle settings like changing indent spacing to 3 or 5. Pasting the code back into the emptied file then will reflect the updated spacing. Eventually, it turns back to 2 spaces again though. This is on PhpStorm 2020.2 by the way

1 comment
Comment actions Permalink

There are currently several unresolved issues related to indentation in mixed php/html code: 

https://youtrack.jetbrains.com/issue/WI-46503

https://youtrack.jetbrains.com/issue/WI-36265

https://youtrack.jetbrains.com/issue/WI-32401

 

Try setting the same tab, indent and continuation indent values for PHP and HTML at File | Settings (Preferences on Mac) | Editor | Code Style.

0

Please sign in to leave a comment.