Bracket coloring is missing in Razor Code files
- Dominant language
- C#
- Stars
- 20.7k
- Forks
- 4.3k
- PR merge metrics
- PR metrics pending
Description
## Is this a Bug or Feature request?:
Bug
## Steps to reproduce:
------------------- Please fill in this section -------------------------
Open any .razor file that has a @code { } section
## Description of the problem:
------------------- Please fill in this section -------------------------
Beyond the opening and closing braces for the @code block, the rest of the braces are the default color. Also the indication of bracket pairs is not shown when clicked inside a pair of brackets (setting "editor.guides.bracketPairs")
Expected behavior:
Colorized brackets
Actual behavior:
Not colorized
## Logs
#### OmniSharp
------------------- Please fill in this section -------------------------
To find the OmniSharp log, open VS Code's "Output" pane, then in the dropdown choose "OmniSharp Log".
#### Razor
Expand
```
-- Starting Issue Data Collection--
[Razor.LanguageClient.Cohost.CohostDocumentPullDiagnosticsEndpointBase`2[[Roslyn.LanguageServer.Protocol.DocumentDiagnosticParams, Microsoft.CodeAnalysis.LanguageServer.Protocol, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35],[Roslyn.LanguageServer.Protocol.FullDocumentDiagnosticReport, Microsoft.CodeAnalysis.LanguageServer.Protocol, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]] Getting diagnostics for E:\source\DownloadExam\Components\Pages\Error.razor
[LanguageServices.Razor.LanguageClient.Cohost.CohostOnAutoInsertEndpoint] Resolving auto-insertion for E:\source\DownloadExam\Components\Pages\Error.razor
[LanguageServices.Razor.LanguageClient.Cohost.CohostOnAutoInsertEndpoint] Calling OOP to resolve insertion at (41, 2) invoked by typing '
'
[Razor.LanguageClient.Cohost.CohostDocumentPullDiagnosticsEndpointBase`2[[Roslyn.LanguageServer.Protocol.DocumentDiagnosticParams, Microsoft.CodeAnalysis.LanguageServer.Protocol, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35],[Roslyn.LanguageServer.Protocol.FullDocumentDiagnosticReport, Microsoft.CodeAnalysis.LanguageServer.Protocol, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]] Getting C# diagnostics for E:\source\DownloadExam\obj\Debug\net9.0\Microsoft.CodeAnalysis.Razor.Compiler\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Components_Pages_Error_razor.g.cs
[Razor.LanguageClient.Cohost.CohostDocumentPullDiagnosticsEndpointBase`2[[Roslyn.LanguageServer.Protocol.DocumentDiagnosticParams, Microsoft.CodeAnalysis.LanguageServer.Protocol, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35],[Roslyn.LanguageServer.Protocol.FullDocumentDiagnosticReport, Microsoft.CodeAnalysis.LanguageServer.Protocol, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]] Calling OOP with the 0 C# and 0 Html diagnostics
[Diagnostics.RazorTranslateDiagnosticsService] No diagnostics remaining after filtering.
[Diagnostics.RazorTranslateDiagnosticsService] No diagnostics remaining after filtering.
[Microsoft.CodeAnalysis.Remote.Razor.SemanticTokens.RazorSemanticTokensInfoService] Requesting C# semantic tokens for host version -999, correlation ID 580f05e6-8f0d-44e5-a97e-55093d2ae98f, and the server thinks there are 174 lines of C#
[Microsoft.CodeAnalysis.Remote.Razor.SemanticTokens.RazorSemanticTokensInfoService] Returned 215 semantic tokens for span (0,0)-(46,0) in file:///E:/source/DownloadExam/Components/Pages/Error.razor.
[Razor.LanguageClient.Cohost.CohostFoldingRangeEndpoint] Getting folding ranges for E:\source\DownloadExam\Components\Pages\Error.razor
[Razor.LanguageClient.Cohost.HtmlDocumentSynchronizer] TrySynchronize for E:\source\DownloadExam\Components\Pages\Error.razor as at Checksum aNqXi9Qi79a0s1EbmIJ/5w== from workspace version 130
[Razor.LanguageClient.Cohost.HtmlDocumentSynchronizer] Going to start working on Html for E:\source\DownloadExam\Components\Pages\Error.razor as at Checksum aNqXi9Qi79a0s1EbmIJ/5w== from workspace version 130
New content for 'file:///e%3A/source/DownloadExam/Components/Pages/Error.razor', updating 'e:\source\DownloadExam\Components\Pages\Error.razor__virtual.html', checksum 'aNqXi9Qi79a0s1EbmIJ/5w=='.
[Services.HtmlRequestInvoker] Making Html request for textDocument/foldingRange on E:\source\DownloadExam\Components\Pages\Error.razor, checksum aNqXi9Qi79a0s1EbmIJ/5w==
[Razor.LanguageClient.Cohost.CohostFoldingRangeEndpoint] Calling OOP with the 3 html ranges, so it can fill in the rest
[Razor.LanguageClient.Cohost.CohostFoldingRangeEndpoint] Got a total of 8 ranges back from OOP
[Razor.LanguageClient.Cohost.HtmlDocumentSynchronizer] TrySynchronize for E:\source\DownloadExam\Components\Pages\Error.razor as at Checksum aNqXi9Qi79a0s1EbmIJ/5w== from workspace version 130
[Razor.LanguageClient.Cohost.HtmlDocumentSynchronizer] Already finished that version for E:\source\DownloadExam\Components\Pages\Error.razor
[Services.HtmlRequestInvoker] Making Html request for textDocument/documentColor on E:\source\DownloadExam\Components\Pages\Error.razor, checksum aNqXi9Qi79a0s1EbmIJ/5w==
[Razor.LanguageClient.Cohost.CohostDocumentPullDiagnosticsEndpointBase`2[[Roslyn.LanguageServer.Protocol.DocumentDiagnosticParams, Microsoft.CodeAnalysis.LanguageServer.Protocol, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35],[Roslyn.LanguageServer.Protocol.FullDocumentDiagnosticReport, Microsoft.CodeAnalysis.LanguageServer.Protocol, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]] Getting diagnostics for E:\source\DownloadExam\Components\Pages\Error.razor
[LanguageServices.Razor.LanguageClient.Cohost.CohostOnAutoInsertEndpoint] Resolving auto-insertion for E:\source\DownloadExam\Components\Pages\Error.razor
[LanguageServices.Razor.LanguageClient.Cohost.CohostOnAutoInsertEndpoint] Calling OOP to resolve insertion at (42, 2) invoked by typing '
'
[Razor.LanguageClient.Cohost.CohostDocumentPullDiagnosticsEndpointBase`2[[Roslyn.LanguageServer.Protocol.DocumentDiagnosticParams, Microsoft.CodeAnalysis.LanguageServer.Protocol, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35],[Roslyn.LanguageServer.Protocol.FullDocumentDiagnosticReport, Microsoft.CodeAnalysis.LanguageServer.Protocol, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]] Getting C# diagnostics for E:\source\DownloadExam\obj\Debug\net9.0\Microsoft.CodeAnalysis.Razor.Compiler\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Components_Pages_Error_razor.g.cs
[Razor.LanguageClient.Cohost.CohostDocumentPullDiagnosticsEndpointBase`2[[Roslyn.LanguageServer.Protocol.DocumentDiagnosticParams, Microsoft.CodeAnalysis.LanguageServer.Protocol, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35],[Roslyn.LanguageServer.Protocol.FullDocumentDiagnosticReport, Microsoft.CodeAnalysis.LanguageServer.Protocol, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]] Calling OOP with the 0 C# and 0 Html diagnostics
[Diagnostics.RazorTranslateDiagnosticsService] No diagnostics remaining after filtering.
[Diagnostics.RazorTranslateDiagnosticsService] No diagnostics remaining after filtering.
[Microsoft.CodeAnalysis.Remote.Razor.SemanticTokens.RazorSemanticTokensInfoService] Requesting C# semantic tokens for host version -999, correlation ID a3e36ae3-5500-4b6c-808a-6c72334aa582, and the server thinks there are 175 lines of C#
[Microsoft.CodeAnalysis.Remote.Razor.SemanticTokens.RazorSemanticTokensInfoService] Returned 215 semantic tokens for span (0,0)-(47,0) in file:///E:/source/DownloadExam/Components/Pages/Error.razor.
[Razor.LanguageClient.Cohost.CohostFoldingRangeEndpoint] Getting folding ranges for E:\source\DownloadExam\Components\Pages\Error.razor
[Razor.LanguageClient.Cohost.HtmlDocumentSynchronizer] TrySynchronize for E:\source\DownloadExam\Components\Pages\Error.razor as at Checksum PMnAjYL2LbJ7ZcyVmS5VMQ== from workspace version 131
[Razor.LanguageClient.Cohost.HtmlDocumentSynchronizer] Going to start working on Html for E:\source\DownloadExam\Components\Pages\Error.razor as at Checksum PMnAjYL2LbJ7ZcyVmS5VMQ== from workspace version 131
New content for 'file:///e%3A/source/DownloadExam/Components/Pages/Error.razor', updating 'e:\source\DownloadExam\Components\Pages\Error.razor__virtual.html', checksum 'PMnAjYL2LbJ7ZcyVmS5VMQ=='.
[Services.HtmlRequestInvoker] Making Html request for textDocument/foldingRange on E:\source\DownloadExam\Components\Pages\Error.razor, checksum PMnAjYL2LbJ7ZcyVmS5VMQ==
[Razor.LanguageClient.Cohost.CohostFoldingRangeEndpoint] Calling OOP with the 3 html ranges, so it can fill in the rest
[Razor.LanguageClient.Cohost.CohostFoldingRangeEndpoint] Got a total of 8 ranges back from OOP
[Razor.LanguageClient.Cohost.CohostDocumentPullDiagnosticsEndpointBase`2[[Roslyn.LanguageServer.Protocol.DocumentDiagnosticParams, Microsoft.CodeAnalysis.LanguageServer.Protocol, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35],[Roslyn.LanguageServer.Protocol.FullDocumentDiagnosticReport, Microsoft.CodeAnalysis.LanguageServer.Protocol, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]] Getting diagnostics for E:\source\DownloadExam\Components\Pages\Error.razor
[Razor.LanguageClient.Cohost.CohostDocumentPullDiagnosticsEndpointBase`2[[Roslyn.LanguageServer.Protocol.DocumentDiagnosticParams, Microsoft.CodeAnalysis.LanguageServer.Protocol, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35],[Roslyn.LanguageServer.Protocol.FullDocumentDiagnosticReport, Microsoft.CodeAnalysis.LanguageServer.Protocol, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]] Getting C# diagnostics for E:\source\DownloadExam\obj\Debug\net9.0\Microsoft.CodeAnalysis.Razor.Compiler\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Components_Pages_Error_razor.g.cs
[Razor.LanguageClient.Cohost.CohostDocumentPullDiagnosticsEndpointBase`2[[Roslyn.LanguageServer.Protocol.DocumentDiagnosticParams, Microsoft.CodeAnalysis.LanguageServer.Protocol, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35],[Roslyn.LanguageServer.Protocol.FullDocumentDiagnosticReport, Microsoft.CodeAnalysis.LanguageServer.Protocol, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]] Calling OOP with the 0 C# and 0 Html diagnostics
[Diagnostics.RazorTranslateDiagnosticsService] No diagnostics remaining after filtering.
[Diagnostics.RazorTranslateDiagnosticsService] No diagnostics remaining after filtering.
[Razor.LanguageClient.Cohost.HtmlDocumentSynchronizer] TrySynchronize for E:\source\DownloadExam\Components\Pages\Error.razor as at Checksum PMnAjYL2LbJ7ZcyVmS5VMQ== from workspace version 131
[Razor.LanguageClient.Cohost.HtmlDocumentSynchronizer] Already finished that version for E:\source\DownloadExam\Components\Pages\Error.razor
[Services.HtmlRequestInvoker] Making Html request for textDocument/documentColor on E:\source\DownloadExam\Components\Pages\Error.razor, checksum PMnAjYL2LbJ7ZcyVmS5VMQ==
-- Stopping Issue Data Collection--
```
## Workspace information
#### Razor document:
Expand
```Razor
@page "/Error"
@using System.Diagnostics
Error
Error.
An error occurred while processing your request.
@if (ShowRequestId)
{
Request ID: @RequestId
}
Development Mode
Swapping to Development environment will display more detailed information about the error that occurred.
The Development environment shouldn't be enabled for deployed applications.
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development
and restarting the app.
@code{
[CascadingParameter]
private HttpContext? HttpContext { get; set; }
private string? RequestId { get; set; }
private bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
protected override void OnInitialized() =>
RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier;
private void Test()
{
Console.WriteLine("Test");
for(var i=0; i < 10; i++)
{
}
}
}
```
#### Projected CSharp document:
Expand
```C#
Cohosting is on, client has no access to CSharp content
```
#### Projected Html document:
Expand
```Html
/*~*/ /*~~~~*/
/*~~*/ /*~~~~~~~~~~~~~~*/
Error
Error.
An error occurred while processing your request.
~~~ /*~~~~~~~~~~~*/
~
Request ID: /*~~~~~~*/
~
Development Mode
Swapping to Development environment will display more detailed information about the error that occurred.
The Development environment shouldn't be enabled for deployed applications.
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development
and restarting the app.
/*~~*/
/*~~~~~~~~~~~~~~~~*/
/*~~~*/ /*~~~~~~~~*/ /*~~~~~~~*/ ~ /**/ /**/ ~
/*~~~*/ /*~~~*/ /*~~~~~*/ ~ /**/ /**/ ~
/*~~~*/ /**/ /*~~~~~~~~~*/ ~~ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*~~~~~*/ /*~~~~*/ /**/ /*~~~~~~~~~~~*/ ~~
/*~~~~~*/ ~ /*~~~~~~~~~~~~~~~~*/ ~~ /*~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*~~~*/ /**/ /*~~*/
~
/*~~~~~~~~~~~~~~~~~~~~~~*/
/*~~~*/ /**/ ~ ~ ~~~ /**/
~
~
~
~
```
## Machine information
**VSCode version**: 1.103.1
**Razor.VSCode version**: 2.88.42
#### `dotnet --info`
Expand
```
.NET SDK:
Version: 9.0.304
Commit: f12f5f689e
Workload version: 9.0.300-manifests.407ced12
MSBuild version: 17.14.16+5d8159c5f
Runtime Environment:
OS Name: Windows
OS Version: 10.0.26100
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\9.0.304\
.NET workloads installed:
[aspire]
Installation Source: SDK 9.0.300, VS 17.14.36408.4, VS 17.14.36408.4
Manifest Version: 8.2.2/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.2.2\WorkloadManifest.json
Install Type: Msi
Configured to use loose manifests when installing new manifests.
Host:
Version: 9.0.8
Architecture: x64
Commit: aae90fa090
.NET SDKs installed:
3.1.426 [C:\Program Files\dotnet\sdk]
5.0.408 [C:\Program Files\dotnet\sdk]
6.0.136 [C:\Program Files\dotnet\sdk]
6.0.321 [C:\Program Files\dotnet\sdk]
6.0.428 [C:\Program Files\dotnet\sdk]
7.0.120 [C:\Program Files\dotnet\sdk]
7.0.317 [C:\Program Files\dotnet\sdk]
7.0.410 [C:\Program Files\dotnet\sdk]
8.0.119 [C:\Program Files\dotnet\sdk]
8.0.206 [C:\Program Files\dotnet\sdk]
8.0.316 [C:\Program Files\dotnet\sdk]
8.0.413 [C:\Program Files\dotnet\sdk]
9.0.304 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.19 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
```
#### Extensions
|Extension|Author|Version|
|---|---|---|
|base64|m4ns0ur|1.0.0|
|copilot|GitHub|1.356.1733|
|copilot-chat|GitHub|0.30.1|
|csdevkit|ms-dotnettools|1.50.11|
|csharp|ms-dotnettools|2.88.42|
|data-workspace-vscode|ms-mssql|0.6.3|
|hexeditor|ms-vscode|1.11.1|
|hl7tools|RobHolme|2.0.7|
|live-server|ms-vscode|0.4.15|
|markdown-all-in-one|yzhang|3.6.3|
|material-icon-theme|PKief|5.25.0|
|mssql|ms-mssql|1.34.0|
|night-owl|sdras|2.1.1|
|quicktype|quicktype|23.0.170|
|rest-client|humao|0.25.1|
|sql-bindings-vscode|ms-mssql|0.4.1|
|sql-database-projects-vscode|ms-mssql|1.5.3|
|TabOut|albert|0.2.2|
|vscode-azureappservice|ms-azuretools|0.26.3|
|vscode-azurefunctions|ms-azuretools|1.18.1|
|vscode-azureresourcegroups|ms-azuretools|0.11.1|
|vscode-dotnet-runtime|ms-dotnettools|2.3.7|
|vscodeintellicode-csharp|ms-dotnettools|2.2.3|
|vsctoix|a-bentofreire|4.0.13|
|xml|DotJoshJohnson|2.5.1|;
Contributor guide
Research direction
Reproduce the problem in the provided .razor document, focusing on the @code block and nested braces with bracket-pair guides enabled. Trace the Razor semantic-token and HTML request paths mentioned in the logs, including RazorSemanticTokensInfoService and HtmlDocumentSynchronizer; done means braces in Razor code are colorized and matching-pair indicators appear when the cursor is inside a pair.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100