VS 2015 Razor Autocomplete/Intellisense dropdown hides immediately after dropdown

后端 未结 8 508
醉酒成梦
醉酒成梦 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:

    <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.

    0 讨论(0)
  • 2020-12-13 06:45

    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

    0 讨论(0)
  • 2020-12-13 06:45

    I had the same error and I fixed it by deleting all the files of the component model cache.

    This is the path:

    Users\YourName\AppData\Local\Microsoft\VisualStudio\14.0\ComponentModelCache

    Hope that helps

    0 讨论(0)
  • 2020-12-13 06:49

    Whenever this annoying thing happens to me, I just put an extra dot and then it works. I have to put the extra dot every time. For example, if I write this and intellisence flashes and disappears:

    @Html.TextBoxFor(m => m. 
    

    then I just do this:

    @Html.TextBoxFor(m => m..
    

    And intellisense will now show after first dot. I have made this a habit until MS has a fix for it.

    0 讨论(0)
  • 2020-12-13 06:56

    Just make sure the ) does not touch the text you are editing, and the popup will stay up.

    Instead of...

    @Html.Partial("ManageGrid", Model.)

    Use...

    @Html.Partial("ManageGrid", Model. )

    The intellisense seems to get confused by touching close parenthesis. Not ideal, but this was the only way I could get it to work for me consistently.

    0 讨论(0)
  • 2020-12-13 06:59

    Instead of...

    @Html.Partial("ManageGrid", Model.)
    

    Use...

    @Html.Partial("ManageGrid", Model.
    
    0 讨论(0)
提交回复
热议问题