-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VS Code freeze on specific line #460
Comments
One more example (harder one):
|
Performance for the first example Details
|
@jeff-hykin the pattern seems to spend a lot of time in the recursive template matching, if that could be made more atomic, that would help. Additionally, it may be a bit of a hack but it might be possible to add a wrapper that looks ahead for Something like:
Edit: the wrapper won't work, if a line contains |
Thanks for posting this, sorry I've been gone for awhile. This looks like it is going to be a really tough fix. First its hard because there's the possibility of comparison vs templating ex: Hopefully there's some major inefficiency we can fix, but I imagine were going to have to make some major assumptions, or straight up limit the length of a valid type in order to get rid of this freezing. |
Nothing will do better highlighting than clang (semantic highlighting). I think that highlighter's performance is more important than accuracy, so I guess incorrect highlighting is better than slow (but not in case like #428 :) ). I saw in a dev tools a lot of heavy regular expressions are executed each time I type some letter. |
Yeah @Yanpas it wouldn't be surprising to me if this repo had the largest/heaviest regex on github, I can't think of any other situation where such a big pattern would be needed |
I found an inefficiency with the <> pattern and fixed it with @matter123 the template_call had a maybe(@spaces) after it that was causing the catastrophic backtracking, which was being used in qualified type, which was being used in function definition. I also improved the scope resolution method for qualified type which I believe also helped performance. |
Pulled in the latest changes. Thank you for the fix! |
It looks like for the line in the original issue this is fixed 🎉 |
I hit a repro (VS Code UI freeze) with the following (test) code:
Let me know if I should file a different issue. |
I think this is the right issue, thanks for the additional example |
Looking at this again, while the other example is likely just going to be difficult, your example @sean-mcmanus should be solvable. It still might be awhile before its addressed, and so that this issue doesn't slow everything down a workaround/shutoff for large numbers of <>'s might be introduced to prevent freezing. |
@jeff-hykin any update on a change to prevent freezing? It's been a while since pulled in updates because of this and I want to get all the other good fixes! |
Thanks for pulling this up again, I think the fix for the issue you posted was actually the cause of this freezing. Next time I work at the syntax, I'll try building a workaround for this. |
@alexr00 I do have a question though, did the original example have a semicolon at the end? or was it the beginning type of a function definition? |
The original example did not have a semicolon at the end. It could have been the beginning type of a function definition since that line was coming from the language server, which was likely because that line was needed for a hover somewhere. |
With the latest grammar, I actually don't see a freeze on any of the three examples that used to freeze: std::tuple_element<0, std::pair<pugi::xml_node, std::map<std::basic_string<char>, pugi::xml_node, std::less<std::basic_string<char> >, std::allocator<std::pair<const std::basic_string<char>, pugi::xml_node> > > > >::type dnode std::_Rb_tree_iterator<std::pair<const long, std::pair<pugi::xml_node, std::map<std::basic_string<char>, pugi::xml_node, std::less<std::basic_string<char> >, std::allocator<std::pair<const std::basic_string<char>, pugi::xml_node> > > > > > dnode_it = dnodes_.find(uid.position) #include <unordered_map>
#include <map>
std::unordered_map<
std::string, std::pair<std::string, std::map<std::string, std::map<std::string, std::map<std::string, std::pair<std::string, std::map<std::string, std::map<std::string, std::map<std::string, std::vector<std::string>>>>>>>>>
>
d; |
It looks like VS Code doesn't freeze on issues like this now, it just also doesn't color them. I will pull the grammar updates into VS Code again, since we want all the recent fixes. |
Yeah same here with the latest version of the extension. I think that must be an optimization from vscode textmate (which is what I'd have it ideally have it be). It's still slow when editing those lines, but doesn't freeze. The solution to this issue would have just been a hack (stop parsing if too long) so I'm going to go ahead and close this issue. Efficient correct parsing of those three simply needs a better parsing engine. |
Originally from microsoft/vscode#92369
Checklist
"C_Cpp.enhancedColorization": "Disabled"
VS Code version 1.43.
The code with a problem is:
The text was updated successfully, but these errors were encountered: