IPWright83 / VSFileNav

Visual Studio extension for rapid finding of files within a solution
21 stars 8 forks source link

Culture based string searching #12

Closed IPWright83 closed 7 years ago

IPWright83 commented 7 years ago

Transcript from:

https://visualstudiogallery.msdn.microsoft.com/cfdf85c2-aaa4-4bdd-b8ea-e22bcc9860af/view/Discussions

**AlexanderMDk**
Hello, very nice extension. I have one issue though: When I type "ac" to search for a file named ActivityFactory.cs, the dialog simply closes the instant I type the "c". This only happens in a certain solution (with around 20 projects, thousands of files). In another solution, where the ActivityFactory.cs file is also present, it works fine. Is there any way to debug this?

**CdTC**
Hi IPWright83, I found that bug AlexanderMDk mentioned.
It's in the StringMatch.cs file and public StringMatch(String fullString, String matchString) function.
Here you have this code:

int startIndex = fullString.ToLower().IndexOf(matchString.ToLower());
...
this.Parts.Add(new StringPart(fullString.Substring(startIndex, length), true));

**CdTC**
And its probably bug int the C# IndexOf(string) implementation.
Because for:
string fullString = "CharSets.hxx";
string matchString = "c";
int startIndex = fullString.ToLower().IndexOf(matchString.ToLower());

returns -1 in Visual Studio 2015. When I changed string matchString to CHAR matchString then it returned 0 as it should.

**CdTC**
ok, sorry for spam and previous useless post, but I found the reason.
IndexOf is CULTURE sensitive so here in Czech Republic we have c, h and ch letters = CharSets.hxx string looks like "Ch|a|r|S|e|t|s|.|h|x|x".

I dont know the best solution for fixing this, but this works for me:
int startIndex = fullString.ToLower().IndexOf(matchString.ToLower(), StringComparison.Ordinal);
or less verbose
int startIndex = fullString.IndexOf(matchString, StringComparison.OrdinalIgnoreCase);

**AlexanderMDk**
Thanks for the fix CdTC, glad I'm not the only one. I tried making the edit in the source code, but I don't know how to build and "deploy" the extension. If I go to the output directory and double-click the VSNav.vsix file, it spins for a few seconds, then complains the extension is not signed (even though it is using the Key.snk file included in the project). Can the author do us a big favour and update the code with the change CdTC suggested? Thanks