AL
AL copied to clipboard
'#pragma warning' is not indented and hinders expand/collapse
Describe the bug When saving an al file, lines starting with '#pragma warning' are not indented. If you did indent, the indent is removed. Then when expanding/collapsing a code block (such as layout{}), the collapse stops at the '#pragma warning' line. Indentation equal to that of comments would make more sense.
To Reproduce
- On a page, in the layout{} section, add a new line '#pragma warning'
- Save the file (indents are removed)
- Collapse the layout{} section
page 50000 MyPage
{
SourceTable = "Sales Header";
layout
{
area(content)
{
#pragma warning disable AA0218
group(General)
{
field(No; Rec."No.")
{
ApplicationArea = All;
}
}
#pragma warning restore AA0218
}
}
}
Expected behavior Indents of '#pragma warning' are treated the same as indents of comments (or, worse but better than now, left alone, like some table relation indents).
Screenshots
5. Versions:
- AL Language: 6.6.425415
- Business Central: W1 17.4 (Platform 17.0.21485.21516 + Application 17.0.16993.0)
This might be inspired by C/C++, where AFAIK the general convention is to keep preprocessor directives in column 0 (I think the leading #
might even have to be there). But yeah, it's not ideal, especially if it interferes functionally with things like expand/collapse.
This might be inspired by C/C++, where AFAIK the general convention is to keep preprocessor directives in column 0 (I think the leading
#
might even have to be there). But yeah, it's not ideal, especially if it interferes functionally with things like expand/collapse.
From what I'm reading, this was also something that they reported over at the vscode/c++ tools by microsoft issue #406
But yes, I'd like to bump this issue as it's making code navigation a headache.
@thloke
This also impacts regions:
As long as the file is not saved and the pragma is still indented, the region is foldable:
And as soon as I save = remove the pragma indentation, the region is broken:
Hi, we have defined an AL custom code folding, which ignores processor directives as expanding and collapsing anchors. We will keep the processor directives in column 0, as per convention, but they will no longer interfere with the code navigation.
@blrobl @JesperSchulz I tried to give this a spin with the v11.0.748446 vsix insider and got it working (I think) only once using the 'Fold Level 1' action. This showed only the field definition, function signature and [IntegrationEvent(false, false)] as lines, which was (almost) perfect!
However, I can't get it working any longer. Is 'Fold Level 1' the proper action, or should we use different commands?
Until now, we are use regions to fold by region, but if we can use standard folding to only show function names without using regions, that would be great !
PS: When folding on level 1, I always get [IntegrationEvent(false, false)]
for the events. Any option to show the signature instead?
UPDATE What I'm trying to achieve is to get some kind of view similar to the 'AL / Code Outline', showing only fields, controls, function names, without var section / code / properties. This can provide a quick overview on how the object is designed.
'Fold Level 3' seems to provide the best result.
I'll let someone from the compiler team answer this one :-)
I'll let someone from the compiler team answer this one :-)
@JesperSchulz Any hint on who to tag to get some feedback?
@blrobl - can you check the feedback above?