codemaid
codemaid copied to clipboard
Add option to override system locale for sorting
Environment
- Visual Studio version: Microsoft Visual Studio Professional 2019/16.11.2
- CodeMaid version: 11.2
- Code language: C++
Description
When I want to sort chunk of lines, eg.:
current
changes
case
I end up with this result:
case
current
changes
And I would expect this:
case
changes
current
I think the issue is due to the fact that my Windows has locale setup for Slovakia/Slovak language, where ch is treated as special letter with ordering between h and i.
I do not want to change my Windows locale for this to work correctly. I would like to have a setting for codemaid, where I can override default system locale.
Steps to recreate
- Setup Windows locale for Slovakia/Slovak language
- Type following lines into c++ file:
current
changes
case
- Select the block
- Let codemaid to do the sorting of the block
Current behavior
Lines are in this order:
case
current
changes
Expected behavior
I would like to have it sorted as in english locale:
case
changes
current
Thanks
Thanks for the suggestion. We do leverage StringComparison.CurrentCulture for sorting and in a few other places. It seems like for most users we would want to stick to that option but in your case you would want a configuration option to set that to StringComparison.InvariantCulture?
https://github.com/codecadwallader/codemaid/blob/dev/CodeMaid/Integration/Commands/SortLinesCommand.cs#L117
Thanks for the reply.
I think StringComparison.InvariantCulture would not help, it probably applies only more rules. Instead I would like to have an option to specify the culture (via GUI, registry, ...) and use it instead of the default CurrentCulture:
myCulture = "en-US";
...
StringComparison.CurrentCulture = CultureInfo.CreateSpecificCulture(myCulture);