VS 2015 Razor Autocomplete/Intellisense dropdown hides immediately after dropdown

后端 未结 8 517
醉酒成梦
醉酒成梦 2020-12-13 05:53

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 te

8条回答
  •  天命终不由人
    2020-12-13 06:43

    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:

    @Html.DisplayFor(m => m.
    

    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();
    
    @Html.DisplayFor(m => m.)
    

    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.

    @Html.RadioButtonFor(m => m.,)
    

    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.

提交回复
热议问题