ionide / ionide-fsgrammar

Shared Textmate Regex Style F# Language Grammar
MIT License
35 stars 36 forks source link

Fix inconsistent arrow color #195

Closed jkillingsworth closed 1 year ago

jkillingsworth commented 1 year ago

The arrow symbols <- and -> are not getting tokenized consistently. There are two different token names being assigned, depending on the context:

It would make sense for the keyword.symbol.arrow.fsharp token name to be consistently applied. See screenshots below.

Before: shot-1

After: shot-2

Here are the relevant VS Code color settings for this example:

"editor.tokenColorCustomizations": {
    "textMateRules": [
        {
            "scope": [
                "source.fsharp keyword"
            ],
            "settings": {
                "foreground": "#569cd6"
            }
        },
        {
            "scope": [
                "source.fsharp constant.language.unit",
                "source.fsharp keyword.symbol"
            ],
            "settings": {
                "foreground": "#d4d4d4"
            }
        },
        {
            "scope": [
                "source.fsharp keyword.symbol.arrow"
            ],
            "settings": {
                "foreground": "#ff8080"
            }
        }
    ]
}

Because keyword.symbol.arrow is a descendant of keyword.symbol, the arrow symbols will just get the regular symbol operator color if the user does not configure a special color for the arrow symbols. Users who do have an explicit setting for the arrow color will see consistent behavior with these changes in effect. I think the correct behavior here is something that will be appreciated by users who might have grown accustomed to the syntax coloring in Visual Studio (i.e. classic Visual Studio, not VS Code). With F#, Visual Studio always makes arrows the same color as keywords, not the same color as operator symbols. See screenshot below.

shot-3

With the changes in this PR in effect, Ionide users can configure their arrow color settings to match the style of Visual Studio. And since the arrow colors can be configured independently of both keyword and operator symbol colors, Ionide can boast a level of flexibility not available in Visual Studio.