Closed RafaelKoch closed 3 years ago
AL doesn't have support for regions at this moment. We have a general issue with adding code folding to the Visual Studios Code extension because of lack of support: https://github.com/Microsoft/vscode/issues/3422
@thpeder , Is it possible or are there any plans to make AL extension for VS Code available on "full visual studio" marketplace?
We do not have any plans to support full Visual Studio. Please see #932 for more details.
I've just manually added this section to al.configuration.json file in al extension folder:
"folding": {
"markers": {
"start": "^\\s*//\\s*#region\\b",
"end": "^\\s*//\\s*#endregion\\b"
}
}
and I can use //#region and //#endregion in al files as in the attached picture now:
Could you include this modification in AL extension?
I've also modified alsyntax.tmlanguage file to get better region colors by adding this based on c# language definition part:
<dict>
<key>begin</key>
<string>(^\s*)?(?=//\s*#region\b)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.preprocessor.region.al</string>
</dict>
</dict>
<key>end</key>
<string>(?!\G)</string>
<key>patterns</key>
<array>
<dict>
<key>begin</key>
<string>//\s*#region</string>
<key>beginCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>keyword.preprocessor.region.al</string>
</dict>
</dict>
<key>end</key>
<string>\n</string>
<key>name</key>
<string>string.unquoted.preprocessor.message.al</string>
</dict>
</array>
</dict>
<dict>
<key>match</key>
<string>^\s*//\s*#endregion\b</string>
<key>name</key>
<string>keyword.preprocessor.region.al</string>
</dict>
and it looks much better now:
It would be even nicer if the two of them // would fall away and only # should be use. A region is not a comment. In addition, a different color than blue would be good e. g. grey as it is not a command statement.
Thanks the both of you for your suggestions. It is on our backlog but we are discussion internally how we want this to look.
I am trying to find a solution that won't require any changes to AL compiler and //#region and //#endregion tags seem to be better as they are already used for regions definition in javascript files in Visual Studio Code:
You can see that they have been defined by VS Code team at the end of this file: https://github.com/Microsoft/vscode/blob/master/extensions/javascript/javascript-language-configuration.json
I agree with you, it might be good to use different color for region/endregion tags but in my example I was again trying to use something that has already been defined by VS Code team and I've decided to copy color settings from C# language definition from this file: https://github.com/Microsoft/vscode/blob/master/extensions/csharp/syntaxes/csharp.tmLanguage.json
As you can see, VS Code team decided to use:
And that's how VS Code shows region for C# files:
Thank you @thpeder
My two cents to add to this thread,
I use the options to collapse and expand some/all functions in the dev environment all the time. I'd love to be able to do the same thing in VS Code - and preferably without having to define regions for each function - but I'm open to how you think to best implement this sort of thing.
I got tired of manually adding the example code of anzwdev to AL every update so I created an extension that does it automatically. https://marketplace.visualstudio.com/items?itemName=BartPermentier.al-toolbox
The regions directive has been released with BC 17 https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/directives/devenv-directive-region
Oh splendid :-) Thanks @NKarolak for pointing this out here. I will close this evergreen feature request then :-)
I also love the code example...
just a quick question: is there a way to use regions in AL? So something like