7

When writing code in Razor, the intellisense drop down box does not work right. It will open up and then close itself less than a second later.

This does not happen to me when I am writing a class or something to that effect, it is only present when I am working on a view.

To explain what happens as I type

  • @Html.
    1. The Intellisense box opens and stays open.
  • @Html.DisplayFor(p => M) //The closing parenthesis is automatically written by VS
    1. The box opens at shows possible inputs that begin with M, but immediately closes.
  • @Html.DisplayFor(p => Model.)
    1. The box opens and shows the properties associated with the model, but then immediately closes.

If however, I add a space:

  • @Html.DisplayFor(p => M )
    1. The box stays open.
  • @Html.DisplayFor(p => Model. )
    1. The box stays open.

Is there a setting or something that is doing this to me?

This problem persists through closing and reopening VS, as well as rebuilding the project.

Using Visual Studio 2015 Professional 2015 Update 2 Working with Razor while doing MVC. I also have Web Essentials installed, if there is a setting in that that might be causing this.

Cœur
  • 37,241
  • 25
  • 195
  • 267
hcaelxxam
  • 616
  • 3
  • 14
  • What happens when you trigger the popup using ctrl-space? It's possible that VS is just catching up parsing your code and realizes the original popup contents is invalid. Some times partially written bad code can cause the whole file to be unparsable which means all the information about what members are available is lost. JetBrains Resharper does a lot better job parsing and auto completing. – Charlie May 11 '16 at 23:41
  • @Charlie ctrl+space will open the popup correctly and it will stay open. How would I go about tracking down "partially written bad code" ? – hcaelxxam May 11 '16 at 23:44
  • Partially written bad code is very situation. The best example is when you start an if statement and it's opening curly brace (maybe from a paste) but do not provide the closing brace. The parser cant find the end of the class so it just gives up until you get all the curly braces to match. You might have some other option or plugin which is 'stealing focus' and causing the popup to disappear. This would be very hard to track down. You could try disabling all your plugins, resetting your settings to default, etc, and seeing if it goes away. Restarting the computer might work too. – Charlie May 11 '16 at 23:48
  • I have a similar setup to hcaelxxam and have the same exact problem. Still haven't found a solution and it has not been fied as of VS2015 Update 3. – rossisdead Aug 10 '16 at 14:35
  • 2
    @rossisdead, glad to know I'm not crazy! The issue persists for me as well; if I ever find a solution, I'll try and remember to let you know. – hcaelxxam Aug 10 '16 at 18:07
  • 1
    I have exact same issue. However, with ctrl-space it stays open. – nico008 Aug 30 '16 at 08:31
  • I've just run into this issue for the first time on a brand new machine, after using VS2015 for a year on my old machine and never seeing it once! How annoying. – chipples Oct 10 '16 at 11:36
  • Check out the answers here... https://stackoverflow.com/questions/36212901/vs-2015-razor-autocomplete-intellisense-dropdown-hides-immediately-after-dropdow/41128392#41128392 – Carter Medlin Dec 13 '16 at 18:48

2 Answers2

0

In my specific case, i was able to solve the problem by installing the latest version Microsoft ASP.NET and Web Tools.

https://marketplace.visualstudio.com/items?itemName=JacquesEloff.MicrosoftASPNETandWebTools-9689

Once I installed it, the problem was gone. It is likely that this update fixed something that could be fixed with an older version, but either way I'm happy.

(I found this in Visual Studio under Tools->Extensions and Updates...->Updates->Visual Studio Gallery)

Carter Medlin
  • 11,857
  • 5
  • 62
  • 68
0

I have very same annoying problem sometimes (VS2015), I don't know rhyme or reason but one example: At top of cshtml file I had...

@{
    Style.
}

When I pressed the "." after Style, the intellisense showed for a split second, then goes away.

I know this is stupid but when I added a return key to add line space - then I get intellisense working proper again.?

@{
    Style.

}

I know it's not a fix but this work around quickly gets me going again.

Deleting all spaces after Style. up to } so it looks like Style.} also worked for me so there may be some special character causing issues.

Tom A
  • 111
  • 1
  • 9