VSCode: How to disable typing shortcuts? - c#

I use VSCode for editing Unity scripts. I have just updated to VSCode 1.65.2.
Before I updated, I was able to type out a for-loop without any problems.
For instance: for(int i=0; i<10; i++) { }, however, now whenever I type the "i<" keys, VSCode auto-adds "async" to my method signature and "await" to the cursor position where I was typing. This is very annoying as I use "i" (i<) for most of my for-loops. Is there a way to disable this feature in VSCode? In addition, I am not sure what the feature is called, so I have not been able to find anything about it myself. I have searched for "Emmet", "Abbreviations", "Suggestions", "Snippets". None of these categories are producing results for me. Even searching for "i<" as a short-code has not produced any results. To be clear, I would like to disable whatever is causing "i<" from converting my method signatures and adding code. If anyone can help with this, it would be much appreciated. Thanks.

OK, finally found something that worked.
In File > Preferences > Settings I enabled Omnisharp: Enable Async Completion according to this question. This worked for me. Thank you.

Related

Is there a way to set/edit unity shortcuts from code?

i'm trying to set-up a shortcut for a unity item from code.
More specifically the Stage/Go Back for the prefab editor.
I know, it's possible (recommendable, even) to edit shortcuts manually, but for what i'm trying to make would be really helpful if it was possible to activate or deactivate the shortcut from code.
I've tried using EditorApplication.ExecuteMenuItem("Stage/Go back"); but it doesn't work with that one.
If it's not possible to do it I'll understand it, thank you!
Thanks to user derHugo i found the API to shortcut management and after a few minutes understanding the code I finally was able to do it. I'll leave the code here in case anyone needs to know how I did this.
/*You need to access ShortcutManager's instance and call to RebindShortcut
RebindShortcut works by passing the id(string) of the shortcut to modify and a KeyCombination
KeyCombination accepts the keyCode and modifier like Shift or Action(Ctrl)
*/
KeyCombination keyCombination = new KeyCombination(KeyCode.O, ShortcutModifiers.Shift); // I don't know how to add more than one modifiers
ShortcutManager.instance.RebindShortcut("Stage/Go Back", new ShortcutBinding(keyCombination));

VS Code C# syntax highlighting bug

using "Visual Studio Code 1.15.1";
I've been using VSCode on my Mac to view some C# code I had written elsewhere, and for some reason, certain things aren't highlighted correctly.
(0) await statements are not highlighted correctly when used with a variable instead of a method call or member accessor.
await someTask; // highlighted as if someTask were a variable of type await
await someThing.SomeTask; // highlighted correctly
await someThing.DoSomething(); // highlighted correctly
(1) using is highlighted as if it were a function instead of a keyword.
using (var spoon = new DisposableSpoon()) {
// ...
}
which didn't happen before.
(2) Some C# 7 features aren't highlighted correctly, such as out variables.
if (map.TryGetValue(key, out TValue val)) {
// ...
}
I'm using the default theme (Dark+), and I don't think I have any major, workspace-breaking plugins enabled (most are just extra themes or support for other languages). Did I accidentally mess up a config or something, or is this a bug?
Edit: (1) is fixed when I change the language from "C#" to "C# (official)". There seem to be multiple C#'s for some reason, but none seem to fix all of the aforementioned bugs. If this is just due to a wonky config or something, how would I revert to default?
The await issue seems like a bug in our built-in c# grammar. I've opened an issue with the grammar we use to track this: https://github.com/dotnet/csharp-tmLanguage/issues/83
I can only repo (1) when not within a class or method body, and I can't repo (2). Can you please file issues for these as well. Include the code, a screenshot, and a short explanation of what looks incorrect: https://github.com/dotnet/csharp-tmLanguage/issues/new

Why would this kind of iteration fail?

It's very clear in the debugger that the dictionary is populated with the values; so why does it not even ENTER the loop at all? I've tried stepping through and I get nothing. It just skips over the loop. Period. I use similar techniques elsewhere and have no issues. This is all on the same thread so I don't understand.
You can see a video of some of the frustration here: http://youtu.be/XernyY5-BAo
I expect the name == e.Name is false
The compiler probably optimized stepping in this case.
or maybe name is null and it has an exception?
I hate to be that guy and answer my own question but I feel like someone else could learn something from my error.
It turns out, the EntityManager from the base class was implemented separately by the base class in this case, it was over-ridden with the new keyword. This was causing the lists to separate and cause all sorts of ugly issues. Don't hide your inheritance trees, everyone! Always double check your implementations! Thanks for all the help everyone; I still don't know why Visual Studio was displaying different values than it should have so if anyone has any information pertaining to why this might be the case - I'll mark you best answer!

Generating c# programatically and compiling...issues

Hello all,
We are creating a dll on the fly for security, we are attempting to have a dll generated and pushed to clients as a challenge response system... with this we are generating 20 variables each with a unique guid and then programatically selecting which one is referenced in the code... however once it compiles this it no longer has the extra dummy variables in it, just the one that it used.
Does anyone know what i can change in the compiler options to make it stop doing this or trick it into no optimizing those out?
I've tried
U = "71d41342-e56e-4643-b12f-24df0b4506ae";
System.Diagnostics.Debug.WriteLine(U);
string V = "";
referencing it in debug writeline but that didnt seem to be enough to get it to keep it. i also added /Od to disablke optimizations but this didnt seem to help either! Any help would be appreciated
You have several options to achieve that:
add those variables to a Dictionary in a consturctor and provide a method to iterate that Dictionary
OR
try putting static reaonly string in front of that declarations

Windows Mobile Click Handler doesn't work

I have an urgent problem..I am developing a windows mobile 6.0 application and the menu item key (which I putted on left side to serve as a back button) only fires when I double click it or after several one clicks..but the items on the right side which in a menu works fine..
I see on the screen that it is clicked(phone vibrates) but it does not fall into the clickitem action.
going crazy someone helps please!!
it does not hit the actionMenuItem_Click_1() method at all if I dont double click
this.actionMenuItem.Text = "select";
this.actionMenuItem.Click += new System.EventHandler(this.actionMenuItem_Click_1);
private void actionMenuItem_Click_1(object sender, EventArgs e)
{
if (actionMenuItem.Text == "Back")
{
if (dialogStack.Count > 0)
{
navigateBack();
}
}
}
First of all - and this is very, very important - never, ever mark a question as urgent. Everyone who asks a question is looking for an answer here and they typically want or need the answer in a short period of time. Marking yours as urgent seems to say that you feel that your question is more important than every other question or that for some reason you should get some sort of priority treatment. My reaction when I see "urgent" is to ignore the question completely.
All answers here are given by volunteers for free. If you have some "urgent" issue that you need an immediate answer to, go pay someone to solve it where they have a contractual obligation to meet your schedule. Otherwise just ask your question.
Second, this is not a good question. The title needs to be a question. "URGENT" is not a question. You' also given us a very generalized behavior description, but we see absolutely no code. We don't see any description of what you've done to try to fix it. Not only are you asking us to give your question priority, you're also asking us to read your mind and divine the behaviors and code that only you see. We don't even know what kind of device this is or whenther it's WinMo Standard or Professional.
So let me shake shaking my magic 8-ball and see what it says about your issue given what we know...it says that your menu click handler calls some long-running method and is therefore interfering with subsequent clicks.
Have you tried debugging? what are the values of actionMenuItem.Text and dialogStack.Count when you step trough your code using the debugger?
Thanks for all answers, I solved it..I am doing some weird stuff in onpaint() that is interfering..

Categories