I was reminded of this while working on related code.
Helgef wrote: ↑23 Jul 2023, 08:00
From my side, there was no intention to consider anything v1. I probably didn't consider this particular case of stacking, only,
it is probably intended to catch cases where the author forgot to write the single-line action.
Although I guessed that was the purpose, I don't think that's particularly helpful. Auto-replace hotstrings are more common, and if you forget the replacement, you'll only get an error if what follows isn't a block or a valid function.
That said, unless trivial to change, without any risk of breaking anything else, it doesn't seem worth bothering with.
That comment seemed odd to me. I didn't see how it could be anything but trivial to change, and without risk of breaking any hotstrings that currently work, given that all it does is show an error message when the X option is used without an action. A quick code review and testing confirmed it.
// Without this check, this
// :X:x::
// {
// }
// would execute the block. But X is supposed to mean "execute this line".
But...
X: Execute.
X means execute. And if you
don't specify X, the hotstring
will execute the block.
A bigger problem with the check is that it prevents this from working:
Code: Select all
#Hotstring X
:*?:@1::
:*?:@2::MsgBox ThisHotkey
I don't see any reason that the action should be required for every hotstring, given how hotstrings permit stacking under other conditions, and hotkeys permit stacking in this exact way.
It might have made sense if we required stacks of hotkeys/hotstrings to terminate with a block/function, but it's too late for that.
There can now be no non-blank lines, including #ifs, in between stacked hotkeys.
This was fixed (in beta) so that multiple hotkey variants (or different hotkeys with different conditions) can be stacked above one function/block, as in v1. I don't know how common it is, but I do it, and there is an example specifically demonstrating it in the documentation for hotkey variants.