dotnet / csharp-tmLanguage

Syntax grammar used for C# colorization
MIT License
69 stars 34 forks source link

`using` scope change #290

Closed alexr00 closed 1 year ago

alexr00 commented 1 year ago

Details

What editor are you seeing the problem in? (e.g. Atom, Visual Studio Code, etc.) VS Code

What version of the editor are you using? 1.81

What color theme are you using? Default, Dark Modern

Repro

using System;
namespace SampleNamespace
{
    class TestClass
    {
        static void Main(string[] args)
        {
            int[] radii = { 15, 32, 108, 74, 9 };
            const double pi = 3.14159;
            foreach (int radius in radii) {
                double circumference = pi * (2 * radius);
                // Display the number of command line arguments:
                System.Console.WriteLine("Circumference = {0:N2}", circumference);
            }
        }

        public void TestMethod()
        {
            ListField = new List<int>();

            List<int> localVar;
            localVar = new List<int>();

            List<int> localVar2 = new List<int>();
        }
    }
}

Current syntax highlighting in VS Code

image

If I were to pull in the latest changes from https://github.com/dotnet/csharp-tmLanguage

image

The scope assigned to using has gone from keyword.other.using.cs to keyword.other.directive.using.cs. Is this intentional?

JoeRobich commented 1 year ago

@alexr00 Thanks for pointing this out. We did intentionally update many of our scopes to be more specific. We grouped many keywords beneath broad categories. I see now that the VS Code themes are expecting keyword.other.using and that the cpp tmLanguage uses keyword.other.using.directive to provide this extra detail.

wise0704 commented 1 year ago

Should the directive keywords (using, static, global, extern alias) then have the scope keyword.other.X.directive instead? In terms of grouping it makes less sense, but it will be compatible with the existing configuration.

But it will be harder to configure all the directive keywords into one colour, as you will then have to configure them individually (unless something like keyword.other.*.directive works? I've never tried).

alexr00 commented 1 year ago

Thanks @JoeRobich! I will update the built-in VS Code themes. Extension provided themes will still be affected.