Closed inventor96 closed 3 years ago
Me too, I can't figure out how to do what you want... 😞
Maybe something like this (it's a work in progress):
{
"beginRegex": "(?:case|default)[^:]*:",
"endRegex": "break;|(.)(?=case|default|\\})",
"foldLastLine": [true, false]
}
which give me
foldLastLine
is modified so that "foldLastLine": [true, false]
:
true
: by defaultfalse
: if the end's group with the index 1
has a valueWhat do you think?
That sounds good to me. Is it easy for me to try out your code changes so I can see how it works with real code instead of only test stuff?
I've made the branch fold-switch
.
Here the steps to test it:
npm i
to install the dependenciesF5
to debug the extension.Or uninstall the extension and install explicit-folding-0.9.2.vsix (remove .zip
) by dropping the file in the list of extensions.
I used the later method for simplicity. Everything looks good in the more complex files I was working in today that had switch statements.
@inventor96 I've published a new version of the extension with the changes you have tested.
Sounds good. I'll close this for now since the original issue has been fixed. Thanks for your work!
Describe the issue
When I have a switch case in PHP that include fallthrough cases (two cases that go to the same set of actions), the folding of all parent folds go away.
To reproduce
Code Example
Settings
Expected behavior
The code should fold at the last case statement in the group for direct fallthrough setups (e.g.
case 'hi2':
in my example). The code should fold at both case statements when there's a fallthrough with other actions (e.g.case 'hello2':
andcase 'hello':
in my example). In both cases, the parent folds should still be available.Screenshots
In this screenshot, I would expect to see folds for lines 3, 4, and 9.
Additional context
I've tried many variations for the
begin(Regex)
,middle(Regex)
keys, as well as played around withnested
andkind
, but I have yet to achieve the desired results. You can see some of my attempts in the commented portions of my folding settings. The settings included here are what were set at the time I took the screenshot.