marcelwgn / IndentRainbow

Visual Studio extension for colorization of indent levels
https://marketplace.visualstudio.com/items?itemName=chingucoding.IndentRainbow
MIT License
32 stars 8 forks source link

CreateVisuals calling ITextSnapshot.GetText causes severe performance problems in large documents #31

Open sharwell opened 1 year ago

sharwell commented 1 year ago

🔗 Originally reported as https://developercommunity.visualstudio.com/t/visual-studio-very-slow-after-last-updat/10232726

The following code should not call GetText(). This method produces both a char[] and string representation of the document behind the scenes, leading to significant GC pressure and user-visible pauses in the UI.

https://github.com/chingucoding/IndentRainbow/blob/f360b230b8bf49c74007a3047cc3dec555b7e1ec/src/IndentRainbow.Extension/Classification/Indent.cs#L112-L131

marcelwgn commented 1 year ago

Thank you for creating this issue. Since you seem more knowledgeable in that area, what would you suggest would be a better solution? Is calling line.Snapshot.TextBuffer.CurrentSnapshot.GetText better?

szalapski commented 11 months ago

I wonder if I am hitting this too. Something seems to be freezing my editor (causing the window to fade out and eventually show the Windows "stopped responding" dialog) in VS Pro. I am not sure if it is IndentRainbow or not.

If you decide to try to fix this, I'd be willing to try it out. If not, thank you for the effort anyway. :)

marcelwgn commented 6 months ago

Thank you for your input @szalapski! Do you have a way one could reproduce this? For example is it a specific project or file? That would make it easier for me to debug this and find the right API for the job