-
Notifications
You must be signed in to change notification settings - Fork 29.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Folding end pattern for C based languages #9605
Conversation
Hi @aminroosta, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! TTYL, MSBOT; |
@aminroosta, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR. |
Thanks @aminroosta! That's the right direction. What's missing is getting the folding pattern per language and not hardcode it. |
@aeschli |
@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. |
@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. |
@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 @rebornix agreed to open an issue in our discussion at VSCodeVim/Vim#493 |
@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: |
@aeschli @aminroosta I've opened an issue #9786 for Folding area management, look forward to your ideas. |
@rebornix Thanks you very much, Great summary of vim folding features ;) @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 |
@sandy081 @aeschli Any chance you can add folding end patterns for the Sept release? The first commit of this PR will fix the issue for |
Closing because no one cares :-) |
@aminroosta The problem is that this is a bigger issue and needs more thinking to be done right. |
@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_}|/\s@EnD\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 @aeschli