Repository navigation
Folding end pattern for C based languages - #9605
Amin Roosta (aminroosta) wants to merge 6 commits into
Conversation
|
Hi Amin Roosta (@aminroosta), I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! TTYL, MSBOT; |
|
Amin Roosta (@aminroosta), Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR. |
|
Thanks Amin Roosta (@aminroosta)! That's the right direction. What's missing is getting the folding pattern per language and not hardcode it. |
|
Martin Aeschlimann (@aeschli) |
|
Martin Aeschlimann (@aeschli) I have two requests / wishes! 1- Could you please add support for C based languages in next vscode release 🙏 2- Is it possible to provide information on folded regions? This will really help vim extensions. |
|
Amin Roosta (@aminroosta) Thanks a lot for your work. I'm sorry, I won't be able to already push this for the July release (last development day is today). This still needs some discussion and thinking. Not everyone likes the closing bracket to be included in the folded section, so we need to a way to let the user configure which folding strategy is applied. I didn't find the time to think about this, input is highly welcome. API for folding regions is a separate request, please open a seperate issue so we can discuss it there. |
|
Martin Aeschlimann (@aeschli) Thanks for your response. Sorry for pushing this issue.
I just checked visual studio settings, even visual studio does not have that option.
I don't think this should be included in user or workspace settings.
Sure! i think Peng Lyu (@rebornix) agreed to open an issue in our discussion at VSCodeVim/Vim#493 |
|
Amin Roosta (@aminroosta) I'm going through all Vim's Fold commands and see what's the exact scope of Folding info we need. Will send a PR in VSCodeVim and open an issue here as well. |
|
From what I know, Sublime does not fold the closing bracket. With Atom there are discussions: |
|
Martin Aeschlimann (@aeschli) Amin Roosta (@aminroosta) I've opened an issue #9786 for Folding area management, look forward to your ideas. |
|
Peng Lyu (@rebornix) Thanks you very much, Great summary of vim folding features ;) Martin Aeschlimann (@aeschli) Thank you for the atom link 👍 if (someTest) {
// do some code here
} else {
// and some other code here
}
///------------ Should collapse to -------------------
if (someText) { ... } else {
// and some other code here
}Maybe we should continue discussion on #9786 |
|
Sandeep Somavarapu (@sandy081) Martin Aeschlimann (@aeschli) Any chance you can add folding end patterns for the Sept release? The first commit of this PR will fix the issue for |
|
Sandeep Somavarapu (@sandy081) Martin Aeschlimann (@aeschli) Any chance you can fix this in Oct release? |
|
Closing because no one cares :-) |
|
Amin Roosta (@aminroosta) The problem is that this is a bigger issue and needs more thinking to be done right. |
|
Martin Aeschlimann (@aeschli) Thanks for your reply.
No, Not actually!
For C based languages this can be fixed easily. right? So why would you wait a couple of months (or a year) when you can support 90% of languages with a 10 minute fix? Why? Atom provides Thanks again and apologies for being impatient 😩 |
Atom editor uses the indentation based folding but also includes the line after a fold-range with a foldEndPattern regex check. The regex pattern is different for each language.
For css: 'foldEndPattern': '(?<!_)__/|^\s_}|/\sEnD\s__/'
For js : 'foldEndPattern': '^\s_}|^\s_]|^\s*)'
Some language extensions in vs code already have this pattern (like php) but not all of them.
With this PR i'm supporting C based languages only (because supporting all languages demands every language extension to be updated).
With this PR the folding behavior will change to match other editors like atom or visual studio or vim or eclipse or ...
Original text:



With this fix:
Without this fix:
related discussion #2971 Martin Aeschlimann (@aeschli)