Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 19, 2025

Tuple deconstruction in for loop initializers was not being tokenized correctly, breaking syntax highlighting for the entire statement and subsequent code.

// Previously broken highlighting
for ((int i, int a1, int a2) = (0, 0, 0); i < 10; i++) { }

// Also affected var syntax
for (var (i, a1, a2) = (0, 0, 0); i < 10; i++) { }

Changes

Grammar (src/csharp.tmLanguage.yml)

  • Added #local-tuple-var-deconstruction to for-statement initializer patterns
  • Added #tuple-deconstruction-assignment to recognize explicit type tuple patterns
  • Added #expression to parse assignment right-hand side

Tests (test/statements.tests.ts)

  • Added test coverage for explicit type tuple deconstruction in for loops
  • Added test coverage for var tuple deconstruction in for loops
Original prompt

This section details on the original issue you should resolve

<issue_title>C# for loop with tuple initializer breaks color highlighting</issue_title>
<issue_description>## Details

What editor are you seeing the problem in?
Visual Studio Code

What version of the editor are you using?
1.101.1

What color theme are you using?
Dark+
AposTheme

Repro

for ((int i, int a1, int a2) = (0, 0, 0); i < 10; i++) { }

(int b1, int b2, int b3) = (0, 0, 0);

Dark+:
Image

AposTheme:
Image</issue_description>

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.

Copilot AI changed the title [WIP] Fix color highlighting issue with tuple initializer in C# Fix syntax highlighting for tuple deconstruction in for loop initializers Dec 19, 2025
Copilot AI requested a review from JoeRobich December 19, 2025 22:18
@JoeRobich JoeRobich marked this pull request as ready for review December 19, 2025 22:22
@JoeRobich JoeRobich merged commit 67c52d6 into main Dec 19, 2025
2 checks passed
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.

C# for loop with tuple initializer breaks color highlighting

3 participants