vscode icon indicating copy to clipboard operation
vscode copied to clipboard

[folding] Collapse ending brace to the same line

Open Tyriar opened this issue 10 years ago • 109 comments

Consider a large JavaScript file

function a() {
  ...
}

function b() {
  ...
}

function c() {
  ...
}

and so on...

Collapsing all currently yields:

function a() { ...
}

function b() { ...
}

function c() { ...
}

and so on...

This would be more readable if the closing brace was on the same line:

function a() { ... }

function b() { ... }

function c() { ... }

and so on...

Here is how other prominent editors handle the above:

Atom

image

Brackets

image

Sublime Text 3

image


VS Code

image

Tyriar avatar Feb 23 '16 16:02 Tyriar

This would not work for languages which do not use punctuation to signify code blocks (i.e python)

Code Folding at the moment uses indentation and so will close everything up to the next line on the same indentation level as the folding line. The implementation would have to change to fold the closing bracket as this would cause issues in some languages

tht13 avatar Feb 24 '16 07:02 tht13

:+1:

joaomoreno avatar Feb 24 '16 08:02 joaomoreno

ping @alexandrudima

joaomoreno avatar Feb 24 '16 08:02 joaomoreno

👍 I like the Atom's way. We save a line and the ending curly brace is not virtually on the same line than the beginning one (unlike Bracket).

pom421 avatar Jul 12 '16 12:07 pom421

👍 definitely, would help so much

danjoa avatar Dec 23 '16 12:12 danjoa

I like how Jetbrains does theirs which matches "bracket" image

I also love being able to fold not only from the first bracket but also the last bracket.

They also have essentially peeking for brackets when they're not on screen so you can see what they belong to. I used to comment what ending brackets belonged to, then I stopped due to the IDE, now I'm feeling lost again w/o it. image

I also really like how notepad++ puts the trailing line as mentioned in Alternative Designs #2

g5codyswartz avatar Feb 01 '17 17:02 g5codyswartz

I'm for the current model, but since people still think there is something to be corrected I think a preference is in order, something like editor.foldingConsumeLastLine: bool

Spown avatar Aug 28 '17 04:08 Spown

Also would prefer a way to make it one-line. I often use the folding in CSS and liked the way the Jetbrains IDEs put the collapsed selectors on one line.

renestalder avatar Nov 24 '17 12:11 renestalder

Can you solve it? I have this same problem uncomfortable, I read the other post about it, but I did not see anything finished that can help me, someone there knows how to solve ?? it really is very uncomfortable working with multiple collapsed lines, because with this line more than "}" it is difficult and confusing to work.

gabrielmaximo avatar Feb 13 '18 19:02 gabrielmaximo

I like the 'Brackets' example, looks clean

manyfew avatar Mar 07 '18 02:03 manyfew

image

It is a good choice to show the number of folded code lines like vim, and make the folded code more visible.

jeasonstudio avatar Apr 02 '18 03:04 jeasonstudio

Hi people!

I think would be nice to see vscode folding with info about amount of lines folded like Netbeans:

screenshot_20170620_215124

BTW: Thank you for this awesome code editor! :smile:

Related issue here: https://github.com/Microsoft/vscode/issues/29155

faustinoaq avatar Apr 22 '18 17:04 faustinoaq

I would really like to see this implemented. But, in the meantime, is there an extension that does that?

ArthaTi avatar May 12 '18 18:05 ArthaTi

I would to see this implemented soon. It's a right pain. Visual Studio working perfectly for collapse and expanding structure.

garpunkal avatar Jun 05 '18 09:06 garpunkal

+1

RueDeRennes avatar Jul 02 '18 13:07 RueDeRennes

#54351 suggests to always show an opening bracket on the first line, even if it's on the next line in the original code

aeschli avatar Jul 20 '18 08:07 aeschli

+1 for many of the ideas here! To recap:

  • Original idea
  • Show number of lines like Net beans as @faustinoaq suggested, but for large blocks only
  • Always show an opening bracket on the first line, even if it's on the next line in the original code, as @aeschli said

To add to this, the folded braces { ... } should change state when you hover over it, like a button, and should unfold when clicked.

Also, I would really not like it to look like the Visual Studio folding style. I really want to see those braces surrounding the ellipses.

NSExceptional avatar Oct 12 '18 01:10 NSExceptional

for large blocks only

@NSExceptional, how much would you consider that to be? 8 lines? 15? 100+? Or maybe a config option?

haykam821 avatar Nov 09 '18 01:11 haykam821

10 I guess. Or configurable from 10, sure.

NSExceptional avatar Nov 09 '18 01:11 NSExceptional

Hey DEVS! Don't you tired of merging similar requests from your users? I have been waiting for this incredibly difficult in the implementation feature for two years now, I've got anything, but not what I really want. If this is something fundamental, not relevant to your philosophy, then just let us know.

antonpegov avatar Dec 10 '18 17:12 antonpegov