vscode-hide-comments
vscode-hide-comments copied to clipboard
Folding comment space
This is not an issue, but a feature request. Currently, when the comments are hidden, the space they occupied remains. I'd love it if that blank space was folded and then the spot was just identified with a 1 or 2 character mark, like ** or --.
Or another option could be, rather than hiding, just fold the comments. Then all multi-line comment blocks and successive single line comments could be folded and unfolded at once.
Hi, first of all thank you @estruyf for this great extension.
I found @mark1502 's feature request as I was also looking for this functionality ... but after a few tials and errors, I realised that it was actually already (somehow) implemented.
In the version I'm currently using (v1.6.0), this is the behaviours that I observe when you trigger the "Hide Comments" button :
- if you have multiple sucessive lines that only contain comments, they will all fold/collapse into a group, with only the first line remaining in place (but this line will now be blank). Any empty lines in between will also fold/collapse into the same group.
- any isolated line of comments will not fold - it will just go blank, but remain visible/in place
This is inconvenient because the code now has lots of blank lines appearing all over the place apparently for no reason. This makes it hard to read.
I think that the following change in behaviour would be an improvement:
- any line that only contains comments - even if isolated - will fold (this means that the " >" to expand/show the hidden lines will now be placed on a line that is not hidden
- any empty lines between a pair of folded/collpased group will also fold into, and all will form the same group
This behaviours would allow a really compact and coherent looking code.
I hope that my explaination is clear. Let me know if you need any clarification.
This would be nice to have. To actually hide the space below hidden comments as well. Currently, my code has a lot of empty space and it's hard to read
Here is my sample code and regex I use to hide it
I came here just to comment this issue. Sorry if someone commented exactly what I'm about to say, but English is not my first language and I might not have understood it correctly. I think the appropiate behaviour to implement this should be:
> Multiline comment or multiple one line comments together are found
Is there text before the comment's beginning in the first line? └ Yes - collapse comment to the first line └ No - Is there a line before the first line? ---└ Yes - collapse comment to the line previous to the first one ---└ No - collapse comment to the first line
Java example:
- Extended
1 ˅ /* comment that cannot be
2 collapsed to the line 0 */
3 ˅ public class Example { /* Multiline
4 comment */
5 ˅ public static void main(String args[]){
6 ˅ // Multiple single
7 // line comments
8 System.out.println("Hello world!");
9 }
10 }
- Hidden (current behaviour)
1 ˅
2
3 ˅ public class Example {
4
5 ˅ public static void main(String args[]){
6 ˅
7
8 System.out.println("Hello world!");
9 }
10 }
- Collapsed
1 ˅ ···
3 ˅ public class Example { ···
5 ˅ public static void main(String args[]){ ···
8 System.out.println("Hello world!");
9 }
10 }
The comment's collapse control should be on the trailing dots (···) instead of the arrow (>|˅), or in a new button, to avoid conflict with the collapsable blocks of actual code.