swekaj / php-foldexpr.vim

Vim folding for PHP with foldexpr
MIT License
41 stars 10 forks source link

Add option to disable folding of braces, brackets etc. #18

Closed artfulrobot closed 9 years ago

artfulrobot commented 9 years ago

Fixes https://github.com/swekaj/php-foldexpr.vim/issues/17

artfulrobot commented 9 years ago

Ah, no, I've broken it! Closing PR until it's fixed.

swekaj commented 9 years ago

Ah, no, I've broken it! Closing PR until it's fixed.

Keep in mind, I have been noticing some bugs related to closures as method arguments and if statements inside switches. I just haven't had time lately to investigate the causes and try to fix them.

artfulrobot commented 9 years ago

OK, this is what I'm trying now.

swekaj commented 9 years ago

Once you add setting the default option for b:phpfold_curlies, I'll take a closer look at this tonight and merge if I don't find any other problems.

swekaj commented 9 years ago

So, it looks like this breaks a couple of situations.

b:phpfold_curlies = 0 prevents correct folding of

function foo(
   $arg1,
   $arg2
) {
   // do things!
}

Lines 1-4 of that end up folded while the function body is unfolded.

b:phpfold_brackets = 0 seems to break when there's a closure passed as an argument to a function call:

foobar(
   function ($arg) {
      // closure things!
   },
   'arg2'
);

At function ($arg) the fold level is increased by 2, but is only decreased by one at the end of the closure. This causes everything after the closure up to the next line that sets a hard fold-level (rather than decreasing by a relative amount) to be included in the fold.

artfulrobot commented 9 years ago

Yes, I've come to the same conclusion. Closing for now.