In VS 2015, only when in Razor (.cshtml) files, roughly half of the time the autocomplete/suggestion list/intellisense doesn't work correctly (sorry, not sure the actual term... when you type an object and hit .
and the list of properties and methods shows to select from)
The behavior is that when I hit .
, the list popups up for a fraction of a second and then closes. It happens so fast I try to do a quick Backspace
, .
, Backspace
, .
cycle a few times to at least see the name I need, but I usually cant' get it and end up having to find the exact name elsewhere from code. Extremely irritating...
It happens sporadically with no real pattern I can find. Here's patterns that I've ruled out:
I've checked all my options (there doesn't seem to be Text Editing options for Razor?), have tried clearing caches, the reloading solution/projects, restarting VS, all of which seem to still provide no pattern.
Has anyone come across this and have any ideas of where else I can look to fix it?
Example Here's an extremely simple example... new project, very little code/files, very simple view. Where the Model.
stops, I should have the usual base methods, and an 'Items' collection. It pops up for a split second then disappears... no lambdas/complex view parsing involved (this is reproducible as well):
Update: Patterns
Things I've noticed:
@model ns.ns.ns.type
, it rarely happens toward the "base" end of the namespaces. It's as I get further towards the type that it happens. This one is intermittent.@Html.DevExpress().
(and other similar, not necessarily DevEx models) will never cause a problem)@Model
(which is where I most want it!). I've found some cases where this is reproducible every time (see above example), but it's about 90%+@models ProjName.Web.App.Subscriptions.Models.AccountCreateVM
... it might fail on Subscriptions
but work fine on Models
)Acc
for AccountCreateVM
causes it to start working again.I haven't found the root cause, but in all cases, CTRL+SPACE
works. This isn't the best, but light years better than nothing at all.
(this shortcut is not one I've used in the past, so this is likely standard behavior, but...) If you're at the dot Model.
and autocomplete list disappears, CTRL+SPACE consistently brings it back up, and when it does come back, it stays! If there's only one possible autocomplete member, it'll auto-fill the member for you upon CTRL+SPACE
This happens for me all throughout VS2015 during lambda statements.
It happens when editing code "mid-document", as in, if there is anything besides a ) or } following where I'm typing. VS appears to be struggling to tell where the current statement ends & the next statement begins.
The following code will consistently fail to trigger Intellisense at the period, even when explicitly invoked.
var subset = initialSet.Where(x => x. var result = new Whatever();
In Razor, it is very common to be editing code between existing text and using lambda statements:
<strong>@Html.DisplayFor(m => m.</strong>
This is probably why you only experience this in Razor.
The way I work around this bug is just to write the ) to close the method.
var subset = initialSet.Where(x => x.) var result = new Whatever(); <strong>@Html.DisplayFor(m => m.)</strong>
Intellisense can then be triggered on the period.
If you're using a method that requires a minimum of more than just the lambda (like RadioButtonFor), you'll also need to put in a comma for each of the extra parameters.
<strong>@Html.RadioButtonFor(m => m.,)</strong>
If Intellisense is appearing, but immediately disappearing again, the best solution I've found so far is to just type a few letters of any known member, then using Ctrl-Left to skip back to the period, and trigger Intellisense again (Ctrl-Space or backspace-retype). This usually gets it to appear and stay. You'll have to delete the characters you typed afterwards, which can be frustrating.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With