-
Notifications
You must be signed in to change notification settings - Fork 29.3k
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
[folding] fold regions #12146
Comments
@mbeckenbach can you provide more information of what you are looking for? I am not familiar with //#region support. Also, is this VS Code specific or is this a feature request for TypeScript? This may be better in TypeScript. |
The full visual studio uses comments to mark code blocks as collapsable in all languages. Depending on the language, the syntax is slightly different as the comment syntax is different. Hard to explain, but web essentials has a nice screenshot of regions in the javascript area: http://vswebessentials.com/features/javascript Regions should exist for all languages. The comment syntax is different but the result schould be the same. |
I think, @mbeckenbach are talking about the #region, current present on c# syntax of Visual Studio. Currently, on C#, #region name_region is used to tell where code will start folding and #endregion tells where code will stop folding. e.g. #region region_sample void MyDummyMethod() void MyDummyMethod2() #endregion In the sample above, the entire region block should fold and "region_sample" should be the label on folding. |
yes, that's what i'm talking about. i'm really missing that feature in other languages like for example ts |
This issue was moved to microsoft/TypeScript#11073 |
@waderyan Not trying to step on any toes here... but just curious why this issue would be moved to Typescript, isn't regions purely aesthetic? That seems like something the Editor should be handling not the language. As others have mentioned this is great for large code bases, obviously its better when you can split things across multiple files but that's not always the case in large projects without adding even more unnecessary complexity. |
@awdogsgo2heaven thank you for your comment. You may be correct and I have been meaning to come back and reopen this issue on our end to gather more feedback from VS Code users. |
I use regions heavily and I have Here's what Visual Studio 2015 does with them: (Above: Image of uncollapsed My team absolutely needs this feature for large files and we can't use VSCode as our main editor without it. |
I would love to see this feature in VS Code as well. #region Name Thank you! |
Bump |
@Fenweldryn What region patterns are common in PHP? |
@pr-yemibedu I added the suggested region markers to fsharp |
@aeschli For php using Javascript pattern is fine: //#region |
Hello, |
Hello, |
Hi @aeschli please can you confirm if the content within the #region and #endregion tags has to be indented for the collapsed visual decoration to appear, as is currently in vscode 16.1? I say this because it would be very handy to use #region to hide the useful, but ugly PowerShell here-string syntax where the @" or @" has to be on the first column of a new line :( |
Support for CSS/SASS/LESS would also be very nice. |
@Ben-Shirley Content inside #region and #endregion does not need to be indented: It can have any indentation. |
Hello,
This style will allow languages like CSS to have fold support (it only has block comments). |
@pr-yemibedu I'm happy to take a PR. But I'd like to limit us to established folding markers, and not come up with new variants, however useful they might be. |
Hello, |
Could vscode support #region and #endregion in PHP ? |
@DarkNami I'm happy to add it if this is already an established marker in PHP. Please file a new issue or even PR. |
What about Python? A simple |
This new feature doesn't seem to work in a HTML file. eg (file: my-app.html): ...
<script>
//region
..... some stuff
//endregion
</script> That would be very usefull. |
Hello, |
Hello, "folding": {
"markers": {
"start": "^\\s*\\/[*]\\s?#region\\s*(.*)\\s*[*]\\/$",
"end": "^\\s*\\/[*]\\s?#endregion\\s*(.*)\\s*[*]\\/$"
}
} This is something that would probably be lost when the program updates itself, but if you want it anyway, that would probably be a possibilty. I always make a copy of the file before I make changes, just in case. Thank you. Good day. |
We want both language aware context folding and artificial region folding for every language. The Ace editor does this for all C style languages (including CSS); it also works for the SqlServer language. https://github.com/ajaxorg/ace/wiki/Non-Standard-Code-Folding |
Hello, So my first sentence is actually out of context here as I started writing it. The rest of my post and example are actually in support of the idea that users should have choice. The code snippet I shared can be hacked into any 1.17.1 editor where they want some non official support for existing code. Thank you. Good day. |
Hello. Thanks for answers, @pr-yemibedu I upvoted #12146 (comment) above, with only note that I'd like it to support arbitrary number of spaces around I'm not interested in editor hacking. I'd like to see this as an officially supported feature that I can refer to when formatting files for a project accessed by multiple developers. |
There should be an option to set initial fold state for specific regions. #region imports folded
// code folded by default
#endregion
#region logic
// code not folded by default
#endregion you can make it even more fancy with region pragmas taking json objects as props #region imports {folded=true, bgColor:'red', fontSize:'8pt'} |
@aeschli can we have the folding markers be arrays instead of just a single string? The logic would match start and end markers pair wise until the shortest list is exhausted. indentRanges.ts 200 can have patterns (an Array) instead of pattern (a String) and just loop over the smaller of the two lists. let minMarker = markers.start.length < markers.end.length ? markers.start.length : markers.end.length;
for (let currentMarker = 0; currentMarker < minMarker; currentMarker++){
let currentPattern = new RegExp(`(${markers.start[currentMarker].source})|(?:${markers.end[currentMarker].source})`);
patterns.push(currentPattern);
} indentRanges.ts 220 can check for list length > 0 with an outer if and then on an inner for loop over each pattern, do all the existing logic you have today inside. if(patterns.length >0){
for(let pattern of patterns){ do existing logic }
} And that would all work (including an update to the schema) with below as an example. "folding": {
"markers": {
"start": ["^\\s*#Region\\b", "^\\s*Region\\b"],
"end": ["^\\s*#End Region\\b", "^\\s*End Region\\b"]
}
} This would promote not having mixed start and end markers. |
Use markers such as //#region and //#endregion to mark folding regions
The text was updated successfully, but these errors were encountered: