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

Code Folding Oddity with Indented Subsequent Lines #5132

Closed
mrkiley opened this issue Apr 10, 2016 · 3 comments
Closed

Code Folding Oddity with Indented Subsequent Lines #5132

mrkiley opened this issue Apr 10, 2016 · 3 comments
Assignees
Labels
*question Issue represents a question, should be posted to StackOverflow (VS Code)

Comments

@mrkiley
Copy link

mrkiley commented Apr 10, 2016

  • VSCode Version: 0.10.11
  • OS Version: Mac OS X El Capitan (10.11.4)

Steps to Reproduce: I honestly am not sure how to reproduce it because I have tried and it does not. So I just took a series of screenshots so that maybe you guys could figure out the pattern. It has not been causing any issues for me at all, except for seeming weird. Hopefully it doesn't affect anyone's code, but I know sometimes a seemingly-small problem can turn out to balloon later on, so I just wanted to help you catch it just in case it does! :)

Problem: When collapsing blocks of code (in this case line # 253), the one in the photo collapses, but then offers me a "minus sign" to collapse an un-collapsable line (# 273). It seems to collapse the one line of whitespace after it (# 274), and that's it. But it is a closing brace.

Hypothesis: Since I have an indented block of code (starting line # 275) beneath the property that I am defining on line # 253, I believe it is trying to alert me that I can close it. If so, and if issue is a feature not a bug, that feature is very confusing/unclear. (see Image 4)

If in fact my hypothesis is correct, may I suggest using a different icon to indicate the ability to collapse indented lines beneath an object (which really does make sense, but again, is unclear in the context of collapsing the code blocks above it), since it is not technically an encapsulated code block that is being collapsed.

Image 1
code folding 1

Image 2
code folding 2

Image 3
code folding 3

Image 4
code folding 4

Awesome IDE and great job folks! =)

@mrkiley mrkiley changed the title Code folding oddity Code Folding Oddity with Indented Subsequent Lines Apr 10, 2016
@aeschli
Copy link
Contributor

aeschli commented Apr 11, 2016

Thanks a lot for the many screenshots. I think what's special in your code is that the closing bracket on line 273 has a larger indent than the code following on line 275.
The currently implemented folding strategy looks solely at the indentation of lines. A folding region starts when a line has a smaller indent than one or more following lines, and ends when there is a line with the same or smaller indent. Empty lines are ignored.
My guess is that if you'd reuce the indentation between line 275 and 416 by one to be the same as on line 273 you'd see a more normal behavior. Can you verify that?

To get smarter here we need to add language knowledge to the indentation strategy. E.g. the knowledge that a } is the end of a block, but never the start.
We have issue #3422 for this.

@aeschli aeschli added the *question Issue represents a question, should be posted to StackOverflow (VS Code) label Apr 11, 2016
@aeschli
Copy link
Contributor

aeschli commented Apr 20, 2016

closing, assuming my assumption was right. Please comment if not...

@aeschli aeschli closed this as completed Apr 20, 2016
@mrkiley
Copy link
Author

mrkiley commented Jul 11, 2016

@aeschli you are correct. Sorry for such a late reply on this! Basically, it looked to me like it was folding based on knowing that I was implicitly making those properties into sub-properties of the property defined at line 253-273. I think it works as expected based on what you said, but certainly would be confusing for anyone who doesn't understand what it's doing. It honestly works fine for when I indent blocks like that, because then I can collapse the implied sub-code.

I also agree with you that language knowledge would help as well.

Thanks!

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*question Issue represents a question, should be posted to StackOverflow (VS Code)
Projects
None yet
Development

No branches or pull requests

2 participants