Wumpf / IncludeToolbox

Visual Studio extension to format, prune, and inspect include directives.
https://marketplace.visualstudio.com/items?itemName=Wumpf.IncludeToolbox
MIT License
51 stars 23 forks source link

Option to add newline between regex groups #5

Closed dakotahawkins closed 8 years ago

dakotahawkins commented 8 years ago

The option defaults to false. If true, when sorting includes with regex precedence groups, a blank line will be added after each matching group of include statements.

dakotahawkins commented 8 years ago

This is the last thing (for the moment) I really wanted! If you have a bunch of includes and are sorting them with regex precedence groups, it's nice to have a blank line between the groups.

I've tried to account for all the corner cases I could think of, like if there's already a blank line before the start of a group.

dakotahawkins commented 8 years ago

I just realized the whole regex function can be made much more efficient. I should have realized it before, but this is something I used in a perl script that had to sort huge files (actually visual studio build logs) using a regex.

Basically it should use a "Schwartzian transform". What that will do is only run the regexes once for everything, instead of several times in the process of doing the compare operation.

.NET may cache regex results behind the scene or something, but since the code I added here has to go through them all another time, I might as well go ahead and add it.

If you want to hold of on this PR I'll just update it, otherwise I'll use a minor version number (1.3.1) since it shouldn't change the behavior at all.

dakotahawkins commented 8 years ago

I'm just going to kill this PR and submit another one with both changes to avoid the churn.