Autocomplete case issue

2019-09-15 06:57发布

问题:

When writing C# in Visual Studio (Community 2017), it's always really bugged me that when I have two similarly-named identifiers, one beginning with upper-case and one beginning with lower-case, that sometimes when I start typing in lower-case it'll autocomplete on the upper-case identifier instead.

This typically happens when I'm assigning from a lower-case parameter to an upper-case field/property, for example:

When I start typing my..., it matches the lower-case myValue until I type the v, at which point it starts to match the upper-case MyValue instead. Obviously I don't want this because then I'll end up with MyValue = MyValue! Is there any way that I can get it to resolve case ambiguities based on the case of the first letter only instead of whatever it's doing now? If I start typing in lower-case then I want it to continue matching the identifier beginning with lower-case as I type more characters.

Edit: Here's an example where it's matching a type instead of a variable. I've typed the parameter name in full, with proper case, and it's still matching a type rather than the variable:

回答1:

For your first example, I tested it on my local side and the result is as the following screenshot, I found the pre-selected completion list is depends on “Most recently used members”, please check this: Visual C# IntelliSense

IntelliSense remembers the members that you have recently selected in the pop-up List Members box for automatic object name completion. The next time you use Member List, the most recently used members are shown at the top.

For your second example, I got the same result as yours. Since we tried to type code into ‘()’ and I assume the VS filtered completion list per some specific rules or principles, which we can also find the rules from the above documents.

If you have some suggestions or idea about this intellisense, please go to Help-Send Feedback-Provide a suggestion… to share it to the VS Product Team, they are willing to hear different suggestions and user voices.



回答2:

I think you may be mistaken about visual studio's selection behaviour: In my experience, Visual Studio case insensitively selects the one I last used, or the first in a list if no use has occurred, by default.

If i typed myv in your case, never having written it before, it would default to the MyValue (first in the list).

If i select the second one down ( myvalue) and then immediately write = myv VS will suggest I mean myValue the second time because I used myValue first time..

That said, one thing I'm certain I've never seen: case sensitive intellisense, and definitely not "case sensitive first char, insensitive other chars" intellisense..