Open ghost opened 3 years ago
Thanks for reporting the issue. I am able to reproduce it.
Our join lines feature is a very basic RegEx find/replace of new line characters with spaces utilizing the VS API. https://github.com/codecadwallader/codemaid/blob/dev/CodeMaid/Integration/Commands/JoinLinesCommand.cs#L89
If you perform the same type of operation directly through Visual Studio's find and replace dialog it definitely does not take as long as it does through the API.
I dug into this, ran the profiler and found the slowdown is caused by the LineChanged listener: https://github.com/codecadwallader/codemaid/blob/253fa4cb31bdfd1d91651db759e9af70df6b5ea7/CodeMaid/Integration/Events/TextEditorEventListener.cs#L73 I am no longer troubled by this issue but I can send a PR if you could tell me a bit how you'd go about it (as I'm not used to this source or extension development), otherwise, feel free to fix it once you have time!
Thanks for running a profiler, that's very helpful. When I look at that I would say the time is spent in ReplacePattern
(41.25%), not in LineChanged
(0.10%). I would also expect ReplacePattern
to be what consumes most of the time since that's where the actual update work is being accomplished. Were there any other events shown coming off of ReplacePattern
that explained the other 41.15%?
@codecadwallader Hmm you are right. I assumed the elapsed time did not include all the calls, as there were no other events within ReplacePattern call tree other than the child LineChanged... And I just ran the profiler again to confirm that. Makes me think there's some interaction with the editor that's not being recorded
Environment
Description
Extremely slow line joining with bigger JSON files
Steps to recreate
Current behavior
The ~50 lines file takes roughly less than half a second on my setup The ~500 lines file causes VS to hang for ~20 seconds on my setup
Expected behavior
I would expect completion time to be linear, and/or that it didn't cause VS to hang while processing the file. "Cleanup active document" happens almost instantly for both files.