Skip to content

Line comments right after preprocessor directives break highlighting. #335

@teo-tsirpanis

Description

@teo-tsirpanis

Consider the following snippet:

public class Foo
{
    void Bar()
    {
#pragma warning disable CS0000 // Internal compiler error
        var x = Baz(1, 2, 3, out object error);
#pragma warning restore CS0000 // Internal compiler error
    }
}

We have a preprocessor directive, a line comment on the same line, and some code right on the next line (not very unusual in real-world code). The line after the directive gets weirdly highlighted:

Image

This does not happen we remove the line comment, or add a blank line or block comment after the directive. It also happens if we add some more line comments in the lines between the directive and the code.

From what I saw, the whole line belongs to textmate scopes meta.preprocessor.cs, source.cs. Maybe that happens because the line comment consumes the end of line, and the directive cannot match (?<=$)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions