Autohotkey Cannot get "A_Language" to work - autohotkey

I use two different languages.
I would like to switch Capslock and LShift, but only for one of them.
Basically I want to do this:
if (A_Language = "0409")
{
Capslock::LShift
LShift::Capslock
}
// else behave like normal
When I write it like this, the keys are always swapped, no matter the language.

You need to use #if to create context-sensitive hotkeys.
You can read more here: http://ahkscript.org/docs/commands/_If.htm
Also, make sure you're running the latest version of AHK, otherwise it might not work.
#if (A_Language = "0409")
Capslock::LShift
LShift::Capslock
#if

Related

VsCode Extension custom CompletionItem disables built-in Intellisense

I am working on a VsCode extension in that I want to provide custom snippets for code completion.
I know about the option of using snippet json files directly, however those have the limitation of not being able to utilize the CompletionItemKind property that determines the icon next to the completion suggestion in the pop-up.
My issue:
If I implement a simple CompletionItemProvider like this:
context.subscriptions.push(
vscode.languages.registerCompletionItemProvider(
{scheme:"file",language:"MyLang"},
{
provideCompletionItems(document: vscode.TextDocument, position: vscode.Position) {
let item = new vscode.CompletionItem('test');
item.documentation = 'my test function';
item.kind = vscode.CompletionItemKind.Function;
return [item];
}
}
)
)
then the original VsCode IntelliSense text suggestions are not shown anymore, only my own. Should I just return a kind of an empty response, like
provideCompletionItems(document: vscode.TextDocument, position: vscode.Position) {
return [null|[]|undefined];
}
the suggestions appear again as they should. It seems to me that instead of merging the results of the built-in IntelliSense and my own provider, the built-in ones get simply overridden.
Question:
How can I keep the built-in IntelliSense suggestions while applying my own CompletionItems?
VsCode Version: v1.68.1 Ubuntu
I seem to have found the answer for my problem, so I will answer my question.
Multiple providers can be registered for a language. In that case providers are sorted
by their {#link languages.match score} and groups of equal score are sequentially asked for
completion items. The process stops when one or many providers of a group return a
result.
My provider seems to provide results that are just higher scored than those of IntelliSense.
Since I didn't provide any trigger characters, my CompletionItems were comteping directly with the words found by the built-in system by every single pressed key and won.My solution is to simply parse and register the words in my TextDocument myself and extend my provider results by them. I could probably just as well create and register a new CompletionItemProvider for them if I wanted to, however I decided to have a different structure for my project.

How does babel option ""auxiliaryCommentBefore" or "auxiliaryCommentAfter" work?

I installed Babel("babel-cli": "^6.26.0") and and made a .babelrc like
{
"auxiliaryCommentBefore": "testBefore",
"auxiliaryCommentAfter": "testAfter"
}
and also made a simple test.js like
var a = 5;
and finally run babel test.js.
It secceded but no comment above is attached..
My expectation is something like below.
testBefore
var a = 5;
testAfter
Is there anything required missing??
The honest answer to your question is "they don't" :D
The specific behavior of those two options are extremely under-defined and I would love to rip them out of Babel entirely, and I would except that I don't want to needlessly break existing users when they upgrade.
If you need to annotate some input code in a particular way, you should write your own Babel plugin to inject whatever you need instead.

Unity How to use Editor Script to remove StateMachineBehaviour

I have a problem use editor script to remove a statemachinebehaviour,like this:
I use AnimatorState.AddStateMachineBehaviour add the behaviour
The Documentation said use Object.Destroy,I use this api,but it appears:
I want to know how to use Editor Script to implement the function as "remove"
thanks for any idea!!!
In order to remove the state machine behaviour you have to grab the state machine behaviour array, remove the behaviour that you're after, and then reassign the array.
Something along these lines should do it:
using UnityEditor;
using UnityEditor.Animations;
//how you invoke this is up to you
[MenuItem("CONTEXT/StateMachineBehaviour/Remove Test")]
public static void RemoveBehaviour(MenuCommand command)
{
Object selection = Selection.activeObject;
AnimatorState state = selection as AnimatorState;
if(state != null)
{
StateMachineBehaviour behaviour = command.context as StateMachineBehaviour;
StateMachineBehaviour[] theBehaviours = state.behaviours;
ArrayUtility.Remove(ref theBehaviours, behaviour);
Undo.RegisterCompleteObjectUndo(state, "Removed behaviour");
Undo.DestroyObjectImmediate(behaviour);
state.behaviours = theBehaviours;
}
}
This will remove the behaviour using the state machine dropdown menu, with added undo and redo support, an optional bonus.
Depending on how you want to handle the remove, this approach will change but in terms of removing the behaviour, this should be what you're after.
Also, for animator state machines the approach is exactly the same, you just cast the selection object to an AnimatorStateMachine instead.
Hopefully this helps.

Problem with Xcode user defaults

Trying to change a few things like I had them in Xcode 3. I can't seem to get user defaults to work. These are the two changes I tried:
defaults write com.apple.Xcode XCCodeSenseFormattingOptions -dict PreExpressionSpacing ""
...which should change
if (...)
to
if(...)
and
defaults write com.apple.Xcode XCCodeSenseFormattingOptions -dict BlockSeparator "\\n"
...which should change
if(...){
}
to
if(...)
{
}
I also tried various permutations and variants like "\n" and others I found through a web search. Nothing makes XC4 behave differently. I can see the change when I use default read, but it does nothing to XC4.
BTW, I also tried something silly like:
defaults write com.apple.Xcode XCCodeSenseFormattingOptions -dict BlockSeparator "this is junk"
No changes whatsoever in XC4.
Any ideas?
Am I doing something wrong?
Thanks!

List in velocity macro, cannot find contains method

I put a list strings as validTypes in velocity. When I do :
#if (${validTypes}.contains("aaa"))
// do something
#end
it throws an error. But when I do :
#foreach (${validType} in ${validTypes})
${validType}
#end
it works fine. Do I need to use velocity tools for this? How do I use it in an eclipse plugin?
Are there any work around without using velocity tools?
The problem here is in curly brackets. Just use
#if (${validTypes.contains("aaa")})
or
#if ($validTypes.contains("aaa"))
instead.
For those who concern, this is how to write if not,
#if (!$validTypes.contains("aaa"))