Sublime Forum

Code folding issues with build 4131

#1

Hi there!

Since build 4131, code folding does not work properly anymore for me. What happens is when I fold a code block in any PHP file, the whole code below gets hidden, event the parts that are not inside the code block.

Reverting to 4130 solves the issue.

0 Likes

#2

Could you provide a sample php file that reproduces the issue ?

0 Likes

#3

Sure. Something as simple as this :

https://www.dropbox.com/s/39innit007io7xi/code_folding.php?dl=0

Try folding line 6 or line 9 to make it happen.

Apparently, after playing a bit, it has something to do with having a string between parenthesis (see line 10).

0 Likes

#4

This issue is caused by php being on of those syntaxes which don’t push into contexts for each code block or group. This causes two punctuations of same scope such as )) or }} or [[ being merged to one folding marker by ST’s new folding engine. This causes ST to not correctly balance those begin and end markers.

The way PHP needs to cooperate with HTML.sublime-syntax I don’t see any feasable way to modify it in a way, syntax based folding would work with its current implementation.

I’ve tried something along those lines with JSP, which is basically HTML embedding Java. Java maintains all those meta.block and meta.group scopes so syntax based folding should work fine, but as soon as it is used/embedded in JSP, we can’t maintain those contexts for sure. So folding is very likely to fail there as well.

See:

1 Like

#5

A workaround is to disable syntax based folding for PHP by createing a Packages/User/PHP Fold.tmPreferences with following content:

<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
    <key>scope</key>
    <string>source.php</string>
    <key>settings</key>
    <dict>
        <key>scopeFoldingEnabled</key>
        <false/>
    </dict>
</dict>
</plist>
0 Likes

#6

Thanks deathaxe, that did the trick! :+1:

And thank you also for your detailed and quite interesting explanations.:slightly_smiling_face:

0 Likes