Vscode: Code Folding Oddity with Indented Subsequent Lines

Created on 10 Apr 2016  路  3Comments  路  Source: microsoft/vscode

  • 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! =)

*question

All 3 comments

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.

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

@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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DovydasNavickas picture DovydasNavickas  路  3Comments

biij5698 picture biij5698  路  3Comments

lukehoban picture lukehoban  路  3Comments

sijad picture sijad  路  3Comments

VitorLuizC picture VitorLuizC  路  3Comments