Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 19, 2025

Thanks for assigning this issue to me. I'm starting to work on it and will keep this PR's description up to date as I form a plan and make progress.

Original prompt

This section details on the original issue you should resolve

<issue_title>Line comments right after preprocessor directives break highlighting.</issue_title>
<issue_description>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 (?<=$)?</issue_description>

<agent_instructions>Be sure to include a test for this scenario.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@JoeRobich
Copy link
Member

@copilot can you try again?

@JoeRobich JoeRobich closed this Dec 19, 2025
@JoeRobich JoeRobich deleted the copilot/fix-highlighting-issue-directives branch December 19, 2025 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Line comments right after preprocessor directives break highlighting.

2 participants