Version Used:
VS17.3p2
Steps to Reproduce:
Type code like below (I use tabs to trigger the bug, but using spaces may also trigger):
using System;
switch (getVirtualKey())
{
case VirtualKey.Up or VirtualKey.Down or VirtualKey.Left or VirtualKey.Right:
{
}
}
// A local function to simulate get operation.
static VirtualKey getVirtualKey() => VirtualKey.Up;
enum VirtualKey
{
Up,
Down,
Left,
Right
}

Then I input a open square bracket [ after the colon token : case label, the highlight will be messed up:
using System;
switch (getVirtualKey())
{
// Insert '[' here
// ↓
case VirtualKey.Up or VirtualKey.Down or VirtualKey.Left or VirtualKey.Right: [
{
}
}
// A local function to simulate get operation.
static VirtualKey getVirtualKey() => VirtualKey.Up;
enum VirtualKey
{
Up,
Down,
Left,
Right
}

It seems that the syntax highlight has been messed up.
See sharplab
If the same operation is applied to the sharplab, the information will be incorrect:
Step 1:

Step 2 (Add '[' token):

Step 3 (Press Ctrl + Z to undo):

The error info is different with the original case.
Expected Behavior:
The syntax is wrong but the info and syntax highlighter behave as normal.
Actual Behavior:
The syntax is wrong, but it seems that the syntax highlighter is broken.
Stacktrace:
StreamJsonRpc.RemoteInvocationException: 指定的参数已超出有效值的范围。
参数名: span
at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__143`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Threading.Tasks.ValueTask`1.get_Result()
at Microsoft.CodeAnalysis.Remote.BrokeredServiceConnection`1.<TryInvokeAsync>d__18`1.MoveNext()
RPC server exception:
System.ArgumentOutOfRangeException: 指定的参数已超出有效值的范围。
参数名: span
在 Microsoft.CodeAnalysis.SyntaxNode.FindNode(TextSpan span, Boolean findInsideTrivia, Boolean getInnermostNodeForTie)
在 Microsoft.CodeAnalysis.ReassignedVariable.AbstractReassignedVariableService`4.<GetLocationsAsync>d__5.MoveNext()
--- 引发异常的上一位置中堆栈跟踪的末尾 ---
在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
在 Microsoft.CodeAnalysis.Classification.AbstractClassificationService.<AddClassificationsInCurrentProcessAsync>d__7.MoveNext()
--- 引发异常的上一位置中堆栈跟踪的末尾 ---
在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
在 Microsoft.CodeAnalysis.Remote.RemoteSemanticClassificationService.<>c__DisplayClass20_0.<<GetClassificationsAsync>b__0>d.MoveNext()
--- 引发异常的上一位置中堆栈跟踪的末尾 ---
在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
在 System.Threading.Tasks.ValueTask`1.get_Result()
在 Microsoft.CodeAnalysis.Remote.RemoteWorkspace.<>c__DisplayClass10_0`1.<<RunWithSolutionAsync>g__TryFastGetSolutionAndRunAsync|0>d.MoveNext()
--- 引发异常的上一位置中堆栈跟踪的末尾 ---
在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
在 System.Threading.Tasks.ValueTask`1.get_Result()
在 Microsoft.CodeAnalysis.Remote.RemoteWorkspace.<RunWithSolutionAsync>d__10`1.MoveNext()
--- 引发异常的上一位置中堆栈跟踪的末尾 ---
在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
在 System.Threading.Tasks.ValueTask`1.get_Result()
在 Microsoft.CodeAnalysis.Remote.BrokeredServiceBase.<RunWithSolutionAsync>d__11`1.MoveNext()
--- 引发异常的上一位置中堆栈跟踪的末尾 ---
在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
在 System.Threading.Tasks.ValueTask`1.get_Result()
在 Microsoft.CodeAnalysis.Remote.BrokeredServiceBase.<RunServiceImplAsync>d__14`1.MoveNext()
Version Used:
VS17.3p2
Steps to Reproduce:
Type code like below (I use tabs to trigger the bug, but using spaces may also trigger):
Then I input a open square bracket
[after the colon token:case label, the highlight will be messed up:It seems that the syntax highlight has been messed up.
See sharplab
If the same operation is applied to the sharplab, the information will be incorrect:
Step 1:
Step 2 (Add '[' token):
Step 3 (Press Ctrl + Z to undo):
The error info is different with the original case.
Expected Behavior:
The syntax is wrong but the info and syntax highlighter behave as normal.
Actual Behavior:
The syntax is wrong, but it seems that the syntax highlighter is broken.
Stacktrace: