microsoft / AL

Home of the Dynamics 365 Business Central AL Language extension for Visual Studio Code. Used to track issues regarding the latest version of the AL compiler and developer tools available in the Visual Studio Code Marketplace or as part of the AL Developer Preview builds for Dynamics 365 Business Central.
MIT License
728 stars 241 forks source link

Wrong Syntax Highlighting for keywords in OptionMembers #7604

Closed pri-kise closed 6 months ago

pri-kise commented 9 months ago

Please include the following with each issue:

1. Describe the bug If you create OptionMembers with keywords then those values are highlighted as keyword.

2. To Reproduce Steps to reproduce the behavior:

  1. Create a new Option field
table 50000 "PTE Dummy"
{
    Caption = 'PTE Dummy';
    DataClassification = CustomerContent;

    fields
    {
        field(1; "No."; Text[20])
        {
            Caption = 'No.';
            DataClassification = CustomerContent;
            NotBlank = true;
        }
        field(10; "My Special Type"; Option)
        {
            Caption = 'My Special Type';
            DataClassification = CustomerContent;
            OptionCaption = 'none,internal,protected,CorrectHighlithing';
            OptionMembers = none,internal,protected,CorrectHighlithing;
        }
    }

    keys
    {
        key(Key1; "No.")
        {
        }
    }

}

3. Expected behavior The keywords shouldn't get this formatting if they are OptionMembers.

4. Actual behavior Currently they are hightlighted as on other places.

5. Versions:

EmilDamsbo commented 6 months ago

Hello, thank you for reporting this issue on syntax highlighting in the AL languge extension. Unfortunately, this is not something that we can resolve well in syntax highlighting. To know whether a word is used in the context of an OptionMembers declaration, that requires just that: Context-awareness. Syntax highlighting lacks such a context, unfortunately, but you can use semantic highlighting in Visual Studio Code to achieve better highlighting awareness.

You can read more about semantic highlight here, but the short solution is to open your VSCode settings and add "editor.semanticHighlighting.enabled": true and enjoy more accurate highlighting.