dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.88k stars 676 forks source link

Long line hangs VSCode #2396

Closed sixlettervariables closed 1 week ago

sixlettervariables commented 6 years ago

Environment data

VS Code version: 1.24.1 (shell 1.7.12, node 7.9.0, commit 24f62626b) C# Extension version: 1.15.2

Steps to reproduce

  1. Begin with a file:
    
    using System.Text.RegularExpressions;

class M { static Regex t = new Regex(@"^T((N'.+?'), (NULL|N'[^']+'),.+?, (NULL|N'\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d.\d+'), (N'[^']+'), (N'[^']+'), (NULL|N'\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d.\d+'), (NULL|N'[^']+'), (N'.+?'), (NULL|N'.+?'), (\d+)\s*, (NULL|N'.+?'), (NULL|N'.+?'), (N'.+?'), (NULL|N'.+?'), (NULL|N'.+?'), (NULL|N'.+?'), (NULL|N'.+?'), (NULL|N'.+?'),.+)$"); // ...smallest repro }


2. Start adding onto the end of the regex, e.g. add ` (NULL|N'.+?'),` prior to the final `.+?\)$`.

## Expected behavior
- VS Code does not hang

## Actual behavior
- VS Code hangs while typing, pasting, etc.

## Troubleshooting
- I think this is due to omnisharp-vscode as renaming the file to `.txt` does not have the same problem.
- Breaking the line up with concatenated strings on multiple lines also resolves the issue.

PS: I realize this is a ridiculously long line of code, but this is just a scratch script.
rchande commented 6 years ago

@DustinCampbell This sounds to me like the Code editor is hanging while evaluating our textmate grammar to classify the file. I would consider this a Code perf bug. Thoughts?

DustinCampbell commented 6 years ago

I'm surprised that this would be slow since it's inside of a string. It could be related to https://github.com/dotnet/csharp-tmLanguage/issues/101 though.

JoeRobich commented 1 week ago

Closing as VS Code has added guards against slow textmate grammar parsing.