
The only required change to have it in AL is to add information about region start and region end to language configuration file. Second case seems much better for us as it uses standard comments and should not have any impact on AL compiler.Īfter a bit of time with google and VS Code source code I’ve found how this functionality has been implemented. If you open C# of JavaScript file in VS Code, you will see, that it is possible to use #region and #endregion tags in C# and //#region and //#endregion tags in JavaScript. If you indent your code properly, it should be enough to be able to collapse content of each procedure or loop, but it is not enough to group a few procedures into a logical region and collapse them all into a single line with just a description. I really like this functionality, so I started searching if there is any way of getting it for AL files in Visual Studio Code.ĭefault Visual Studio Code functionality uses indentation to detect foldable regions. I have made a few modifications to the Macro to support more advanced code collapse.I am using foldable regions in each of my C# project as they allow me to split content of bigger classes into much smaller parts.

Regarding #region in general, this SO Question covers it quite well.

Still, I do find occasions where collapsing functions to their definitions makes browsing through a file much easier. Darin Dimitrov also makes a good argument about limiting the complexity of your JS files. I don't know why - I just entered it first time and use it now :)

StartIndex = text.IndexOf(REGION_START, lastIndex)ĮndIndex = text.IndexOf(REGION_END, lastIndex)
