Skip to content
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

Don't include trailing empty lines at end of code folding #26258

Closed
wants to merge 1 commit into from

Conversation

acls
Copy link

@acls acls commented May 9, 2017

This fixes #3353.

@mention-bot
Copy link

@acls, thanks for your PR! By analyzing the history of the files in this pull request, we identified @alexandrudima and @egamma to be potential reviewers.

@msftclas
Copy link

msftclas commented May 9, 2017

@acls,
Thanks for your contribution.
To ensure that the project team has proper rights to use your work, please complete the Contribution License Agreement at https://cla.microsoft.com.

It will cover your contributions to all Microsoft-managed open source projects.
Thanks,
Microsoft Pull Request Bot

@msftclas
Copy link

msftclas commented May 9, 2017

@acls, thanks for signing the contribution license agreement. We will now validate the agreement and then the pull request.

Thanks, Microsoft Pull Request Bot

@acls acls changed the title Don't include trailing empty lines from end of code folding Don't include trailing empty lines at end of code folding May 9, 2017
@aeschli
Copy link
Contributor

aeschli commented Jun 22, 2017

Could you look into adding a property to the language configuration so that we can distinguish indentation based languages from bracket based languages?
Each language has a language-configuration file. It is read into the language configuration registry. And can be read by the folding strategy.
That would allow us to serve both camps well without compromises.

Note sure about the name of the property, maybe blockEndStyle: 'c-style' || 'off-side'
(see https://en.wikipedia.org/wiki/Code_folding#Indentation-based)

Sorry for not getting to do this myself, but I'm covered with other issues.

@regexus
Copy link

regexus commented Jul 26, 2017

I think we don't need to serve both camps. Ignoring empty lines at the end of the block during folding will probably not affect c-like code much. I have a dev version with changes from acls here on the right side of the screenshot and the release version on the left side. After folding some typescript code we get exactly the same result in both versions:

03_ts_script_folding

But we have some big problems with python code. First let's look how some bad formatted python code was folded in the normal (left) and in the patched version (right) :

01_bad_formatted_python_code

We see that current VS Code version simply hides our formatting problems. Even if the code on the left side looks kind of better after folding, it is still bad formatted, we simply can not see that anymore.

Well formatted code also gets some troubles:

02_simple_python_script

Notice how current release version puts the for loop and the class definition together. This brakes the entire structure of the code and makes it unreadable.

Also if you want to add a new function between two existing folded ones, you get a problem. You can not even start write something, because every newly created empty line will be immediately folded.

VS Code is just amazing. This folding problem slows down my transition from Sublime to VS Code now and I have to stick with the patched version. It would be really nice to get better folding behavior right out of the box though. So please merge it into master or at least insider branch. Thx!

Best regards,
AK

@aeschli
Copy link
Contributor

aeschli commented Sep 20, 2017

I pushed a new language configuration setting to distinguish C-style block language from offSide style languages. Adapted the indentation based folding to use the new setting.
Thanks @acls for the PR which was very helpful.

@aeschli aeschli closed this Sep 20, 2017
@github-actions github-actions bot locked and limited conversation to collaborators Mar 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[folding] should not fold whitespace after function
5 participants