madskristensen / RainbowBraces

A Visual Studio extension
Apache License 2.0
132 stars 7 forks source link

Experimental feature - colorize vertical lines #49

Closed lordfanger closed 1 year ago

lordfanger commented 1 year ago

Hi, can you look at this? It is very ugly and hacks Visual Studio's WpfTextView. But it does it work. :) Can I continue to refine it (lessen reflection, optimize, fix bugs etc...) or discard it entirely because it will never be merged?

madskristensen commented 1 year ago

This is great stuff. Yes, please continue. My only concern here is performance and if it will slow typing down in larger files?

lordfanger commented 1 year ago

It should slow down quite a lot because it does all the reflection and lookups on the main UI thread. But I plan to cache as much as possible and to sort tags off main thread so the search could be a lot faster. I have some juicy .json files with a lot of lines and a lot of curly brackets. With some dottrace help I'll try to do my best to improve performance as much as possible.

lordfanger commented 1 year ago

I did some optimalizations. I had to rewrite the brace pair finding logic a lot and I think the performance is not bad. When I opened the JSON file with 178k lines (I had to increase hardcoded limit) the colorization appears instantly to me with vertical lines colorized a second after it shows up. The problem is that the closing brace can be outside the processing window with overflow set to 200 lines so for that feature it will need to scan the whole file every time. Now it does only when any view is close to end of file.

Anyway it should be a lot faster even without feature enabled.

madskristensen commented 1 year ago

Amazing work. Thank you so much!!

madskristensen commented 1 year ago

It looks so good!!!

When scrolling, the vertical lines lose their adornment and then a moment later they come back. I wonder if there is a way to cache them, so they don't blink in and out when scrolling?

lordfanger commented 1 year ago

The cache is prepared. What I need to investigate is to find proper event to subscribe and reapply rainbow colors. For example on section collapse/expand the colors are not reapplied, new scroll is needed. Tomorrow I'll try to solve it.