VS 2015 Razor Autocomplete/Intellisense dropdown hides immediately after dropdown - razor

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:
The file that's open doesn't seem to matter.
Whether or not I close/reopen the file doesn't seem to matter
Whether I navigate to another file and back doesn't seem to matter
It will work/not work multiple times on and off throughout the same file
It doesn't seem to be relevant to any particular object/property/method
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:
If I'm entering a #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.
In some cases, it works perfectly fine, every single time. For example, I often use DevExpress tools, and have never seen the behavior on any of their extensions (so, #Html.DevExpress(). (and other similar, not necessarily DevEx models) will never cause a problem)
It happens almost all the time when I'm accessing my #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%+
Occasionally, as I work through the object tree, one will fail while the next works (ex: #models ProjName.Web.App.Subscriptions.Models.AccountCreateVM... it might fail on Subscriptions but work fine on Models)
Occasionally, beginning to type the name within autocomplete kicks it back into gear and it starts working again. In the above example, starting to type 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.

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.

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)

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

I use ctrl+j as a temporary solution when I know the content.
Or keep writing without right parenthesis can use the completion:
#Html.LabelFor(m => m.Name

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.

Instead of...
#Html.Partial("ManageGrid", Model.)
Use...
#Html.Partial("ManageGrid", Model.

Related

How to make VS Code's auto-complete more strict?

I love Visual Studio Code, but its Intellisense auto-complete drives me crazy and I make more typos with it than it helps. So I feel I must be using it wrong.
The problem is very hard to explain, so I have a screenshot below:
I typed in thi. I would hope/expect/want that autocomplete would only look for anything to autocomplete that contains thi in consecutive order. But it does not. Instead it looks for anything with the letters t, h, and i in them. They needn't be next to each other, nor does the thing of interest even need to start with t.
I would like to "tame" auto-complete to only find consecutive letters. Is there a way to do this? (I use Python, Javascript, and SQL for most of my work, but I'm hoping the config is cross-language.)
Ideally, I would like the auto-complete to (a) require all letters be consecutive, (b) not require the thing of interest to start with those letters, and (c) ignore upper/lower case. But by far the most important issue to me is resolving (a).
The issue you are having is a feature added in November 2017 update. There is currently no way to turn off fuzzy autocomplete, but the issue is currently open on GitHub and the setting to change this behavior will be added.
In the meantime you can tweak your autocomplete with these settings:
"editor.wordBasedSuggestions": false,
"javascript.nameSuggestions": false,
"editor.snippetSuggestions": "bottom" / inline, none
"editor.suggestSelection: "recentlyUsedByPrefix"
From official docs:
When using the last option, recentlyUsedByPrefix, VS Code remembers which item was selected for a specific prefix (partial text). For example, if you typed co and then selected console, the next time you typed co, the suggestion console would be pre-selected.
This lets you quickly map various prefixes to different suggestions,
for example:
co -> console and con -> const.
And maybe:
"editor.quickSuggestions": {
"other": false,
"comments": false,
"strings": false
},
It doesn't solve your problem completely, but it's the closest you can get without digging through VS Code source and creating an extension.

How do I automate tab selection on a website

Here is the website I am trying to access. I dont want the default tab (Day) though, I want to select the Season tab
https://www.eex.com/en/market-data/power/futures/uk-financial-futures#!/2017/05/23
The link appears to be exactly the same whichever tab is chose making differentiation impossible as far as I can tell.
Any help on this would be much appreciated, using whichever programming method and language is appropriate.
Kind Regards
Barry Walsh
The URL does not change since this is an ajax request, which you can see from MarketDataTableAController's getPageData function. You can read about them here https://developer.mozilla.org/en-US/docs/AJAX/Getting_Started
Ive inspected your html and you seem to be using angular. On further inpection you can see that the tabs have ng-click="setActiveTab(tab)" attribute on them. So whenever user clicks, this function gets executed. It is a matter of using this function with the appropriate tab object to get the content to change. You for example could put setActiveTab(tab) into your controller init method since setActiveTab() calls the forementioned getPageData() function to update the page.
Also the tab you are looking for is page.tabs[5] ($parent.page.tabs[5] if referring from TabController) since this is the tab with the label of season. Pass that to setActiveTab() and it should show you the season instead.
However this might not be a good solution since the tab array ordering might change. Then you would need to loop over all objects in page.tabs and see if tab.label === "Season" and pass that in the function instead or better yet use the $filter service provided by angular which would look more cleaner.
Your code source also seems to be minimized and its not very easy to read.

console logging in google chrome

I am writing a Google Chrome Extension and trying to make the transition to coding in HTML, CSS and Javascript from the kind of coding I did 40 years ago. It's a big learning curve but a little bit of console logging would help a lot. (Who remembers the green phosphor displays on the old iron-core memory Sperry Univacs? Now there was a console that could tell you what was going on - mount a tape, change a diskpack or put more paper in the printer.) But I digress.
Just a few days ago, I was able to send messages to the Google Chrome DOM Inspector console log from my content script or background page like this:
console.log="RECEIVED REQUEST FROM CONTENT SCRIPT PEEK.JS";
Later if I inspected the page where that code was injected, I would see that exact same message on the console. If that line executed four times, I would see four instances of that messages in sequence on the console. It was simple but beautiful.
Now, nothing appears on the console unless I type in "console.log" and in this case I see only the last instance of the message. What's the problem here? Did I toggle something off in the debugger? Am I writing the code wrong? Should it be: "console.log("Message Here");" - (this always returns an error) ?
I have spent literally hours trying to find the answer to this question and I can only surmise that the question is so simple that even a well-educated child could answer it. The alternative is to spend more hours trying to find my bugs thru implication or from alert messages. Better to spend my hours learning how to effectively use the inspector for debugging.
For example, yesterday after restructuring what was once working code so that it would pass an array to background from content instead of background requesting each item successively from content, the extension broke, as might be expected. The console displays one error message: "Error during tabs executeScript: Unknown error." with a link that says "chrome/ExtensionProcessBindings:95" on the far right of that same line. Obviously the error message is almost useless. Clicking on the link brings me to the resources panel which displays a blank frame to the right with the words "background.html" This appears to be useless as well.
How is this information at all helpful? It took me another six hours to figure out that I had moved a variable definition to another place in the code so that it was not defined at the time the executeScript line was executed. Had the error message said that a parameter was undefined in executeScript, I could have found it in about ten minutes.
So back to the original question - I WANT A SIMPLE ANSWER - don't tell me to write a function. I saw the console displaying what I wanted two days ago without writing any functions.
Here is your SIMPLE ANSWER: Instead of
console.log="RECEIVED REQUEST FROM CONTENT SCRIPT PEEK.JS";
You should use
console.log("RECEIVED REQUEST FROM CONTENT SCRIPT PEEK.JS");
For console.log():
https://developer.mozilla.org/en-US/docs/Web/API/console.log
I would recommend searching the Mozilla Developer Network for documentation on JavaScript and many browser technologies.
My general suggestion to help with mistyped or out of scoped variables is to use strict javascript:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions_and_function_scope/Strict_mode
This makes certain JavaScript idioms into errors which are detected earlier, and which give more helpful diagnostics. (The quick version is to put the single line "use strict"; at the top of your js files, or if that causes to many problems you can put it as the first line inside any function to do function-by-function migration.)
The reason why console.log = blah would show blah on the console in some situations is that in JS, <left side> = <right side expression> is an expression which evaluates to the same value as just <right side expression>, but it has the side affect of also assigning to <left side>. (This is similar to C assignment expressions.)
Then, in the context you were in, the console will display the result of any expression evaluation. This is different from explicitly calling console.log() which will display the arguments as the intended side effect of that function.
So in that case you were overwriting the standard console.log function with a string, and the entire expression evaluates to that string value, and the console's builtin behavior (not the console.log() function!) would display the result of your evaluation.
In JS most things are mutable, and you can overwrite all kinds of fields and variables, so be aware of this potential gotcha!
Also, a general recommendation for seeking help on the web:
For sites like StackOverflow is to limit your post to a very specific single question. This is because people with similar problems will come here based on web searches or other links, and they need to figure out if this page helps them with their particular problem quickly. If they have to read through paragraphs with multiple questions or anecdotes, this really slows them down. I would guess that's why this question has been downvoted.
If you have multiple questions, make separate posts. StackOverflow isn't a good site for anecdotes about your experience in the past. FWIW- I personally found your background as a programmer on 70's era machines interesting, but many readers may get lost in the details. Those kinds of anecdotes could make a good blog post.

Access 97 VBA writing code

I found that I can write code just by typing everything or activate element, then click for example OnClick property and write code to between the sub-end sub lines.
One person I met said that one has always use mouse and select the property in which you want to write the code, as it might write something else to some files such that the code won't work.
Is this correct or are those two ways to write code equally good? I'm using Access 97.
The short answer is you CAN do it that way. But it doesn't mean you SHOULD.
With a little experimentation I've found that you can type in event subs directly in the code window, and their creation will be reflected in the properties window. This might not have always been the case in older versions of MS Access.
You can also create them by selecting the Control in the code window's top left pull down, and then selecting the event in the top right pull down.
Why would I choose to use the Code Builder (or at least the second option I provided). Because it prevents you from making mistakes. Both in the name of the control/event and in accidentally creating duplicate Subs. Both of which could be frustrating when debugging your application - how long could you spend looking for a bug because you added an extra "S" to an element name by accident. If you follow through from the properties window, you are guaranteed to be working on the right Sub and that it will be spelled correctly.
Note: I've also found that you can delete the entry in the properties window, but it leaves the code behind in the code window. So to make sure it is really gone, you do have to go into the code window and delete the Sub there.
That's not to say that I never do anything directly in the Code window like that - if I've renamed a control, I'll often update the name in the code window. But then I'll go back through the properties window to verify that I've re-connected the subs properly.
"Look, I'm running with scissors!"

Access 97 - how to edit/explore existing toolbar?

My current job is updating an existing Access97-Project. I haven't worked with Access in a long time and i can't find out, how i can explore a toolbar called "sbmbDrucken" which is obviously user-created. I just need access to the action or the code which is called by the buttons...
Is there any menu entry i missed or do i need special code for self-inspection?
TIA!
There are three different ways for menus/toolbars to be instantiated:
the old way, using macros. Before A95, this was the only way, so a lot of older apps (i.e., those converted from earlier versions) may still use macros for the menus.
defining them by hand, using the CUSTOMIZE function that you get when you right click on a toolbar in Access.
in code, using the Application.Commandbar object.
For the first you can browse your macros and see if any of them are menu macros.
For the last, you can do a search in the code for CommandBar.
For the second, just look at them through the built-in menu customization tools. Keep in mind that you may have to check them off to get them to be visible, and that the list is in no rational order. Likewise, some menus/toolbars are hidden from the customization interface. Also, you might need to look at the CUSTOM toolbar menu item.
I don't have Access 97 on hand but you may take a look of this webpage: http://www.alvechurchdata.co.uk/hints-and-tips/accaddtoolbar.html
It seems that "user-created" toolbars could be defined by handwritten code at form.load or somewhere similar. You may search CommandBars.Add and see if you can find those relevant code segments.
Hope that helps.
In the design mode, you will be able to see the toolbar & actions assigned to each of the button.
Right click on the specific toolbar
Click on Customize...
Right click on the button you would like to edit the action of.
You will be able to see the action (which could either be macro or code).
Let me know, if that doesn't help at all.