nodename/vscode-hacker-typer

Error when recording a macro: command 'nodename.vscode-hacker-typer-fork.recordMacro' not found

Opened this issue · 16 comments

When I attempt to record a macro, I get the following notification: "Command 'HackerTyper: Record Macro' resulted in an error (command 'nodename.vscode-hacker-typer-fork.recordMacro' not found)".

Screen capture showing both the command selected (HackerTyper: Record Macro) and the notification message:

image

VSCode version info:

Version: 1.44.2 (user setup)
Commit: ff915844119ce9485abfe8aa9076ec76b5300ddd
Date: 2020-04-16T16:36:23.138Z
Electron: 7.1.11
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 10.0.18363 [Windows 10]

HackerTyper extension v0.2.1

I've been able to reproduce this issue using the command palette. Will investigate. Could you verify whether using the keyboard shortcut instead of the palette works?
Thanks!

I'm not really sure what the keyboard shortcuts would be since the extension documentation says to use Cmd+Shift+T R and there is no Cmd key on PCs. Using Ctrl+Shift+T seems to bind to "open last group of tabs" (or something similar) by default. Using Ctrl+Shift+P brings up this menu:

image

Which, even more confusingly, shows "HackerTyper: Record Macro" as being associated with Shift+Windows+T R. Typing Shift+Windows+T just selects my Windows toolbar, and hitting "R" after that does nothing since I'm no longer in VSCode.

So at the end of the day I'm not clear on what keyboard shortcut is associated with HackerTyper's Record Macro feature.

I've been attempting to use it by hitting Ctrl+Shift+P, then clicking the first menu item labeled "HackerTyper: Record Macro", which immediately brings up the error I initially reported.

Fixed in 0.2.2, please verify!
The shortcuts use Ctrl+, not Windows+. The menu should now show that properly.

Thanks, that seems to have mostly fixed it! I was able to record and play back a macro, using both Ctrl+Shift+T R, and Ctrl+Shift+P (then selecting HackerTyper: Record Macro). However, the second time I tried it I got a couple of notifications/errors:

command 'nodename.vscode-hacker-typer-fork.recordMacro' not found

and

Command 'HackerTyper: Play Macro' resulted in an error (command 'nodename.vscode-hacker-typer-fork.playMacro' not found)

These errors persisted even after I restarted VSCode.

image

From your screenshot it appears it is in the play state. Currently, record is not available directly from the play state. If you exit the play state (either by playing ll the way through or by cancelling play) then record would be available.
Again, please verify, and if you have suggestions about improving the interaction, please let me know.

I'm still having a problem: When I record a macro and then save it, then play it back, it plays back once all the way through, no problem. (I know it plays through because the status bar says HackerTyper play: atEnd: test where 'test' is the name of my macro that just finished playing.)

But when I attempt to play back that same macro again, I get Command 'HackerTyper: Play Macro' resulted in an error (command 'nodename.vscode-hacker-typer-fork.playMacro' not found).

At that point, attempting to record a macro gives Command 'HackerTyper: Record Macro' resulted in an error (command 'nodename.vscode-hacker-typer-fork.recordMacro' not found). In fact, attempting to cancel recording, play, or record all give an error at that point, as if the plugin is in some state of failure. I have to restart VSCode to get it to work again.

I don't think this is a failure in my understanding of the UI, although certainly if a user attempts to playback in the middle of recording, or record in the middle of playback, I would expect the plugin to give me an error message stating "Can't play a macro while you're recording a macro" or "Can't record a macro while playing a macro" rather than an obtuse "command not found".

atEnd is just like a stop point. It's there because otherwise, if you're typing through the macro, you'll overrun the end and your random keystrokes will show up.

Ok, that's super confusing. I know this is a fork of another plugin that you didn't write so consider this constructive criticism: I'm just looking for the ability to record and play back a series of keystrokes. I don't need the ability to "walk" through them one at at time as if I'm giving a presentation or (ugh) trying to impress my friends. It would be great if "play" gave me the option of playing just once (all the way through, no hitting keys necessary), or through until the cursor hits the end of the file. And I would expect that when play finishes, it's finished, no other keystrokes necessary, so I can immediately play again as few or many time as I want.

Anyway, thanks for your quick response--let me try it again and see if I can get it to work.

Thanks, I've been thinking along those lines too. I also am using it in autoplay mode, which I just added recently.

I think I'll change that atEnd behavior so that you have to put a stop point at the end when recording if you want it.

Now that I understand I have to hit Enter to really to get it to end playing, it seems to work fine. For my needs, though, the fact that replaying always resets the workspace to the macro's starting point makes this plugin completely unusable since I'm looking to be able to apply a series of keystrokes to any given file regardless of what "state" it started in. In other words, I would expect that a series of keystrokes is just that, nothing more and nothing less, with no assumptions about my workspace's starting point. What you have here is great for presentations, but I'm using it for development.

It's a shame since this looks like the only plugin that comes close to what I want. The other macro-related plugins all require you to laboriously code the desired keystrokes into a config file, which to my mind is complete insanity.

I don't know if you've ever used TextPad (textpad.com) but their macro recording/playback is super simple, and in fact is what I'm trying to duplicate. Not being able to do that in VSCode is a show-stopper for me since I use it so often.

I'll take that as a feature request!

Awesome, thanks! And FWIW, I'd be happy to pay/donate if it does what I want.

Can you give examples of some macros you'd create?

Starting text:

	<td foo="one"></td>
	<td bar="whocares1"></td>
	<td foo="two" bar="whocares2"></td>
	<td bar="whocares3" foo="three"></td>
	<td bar="whocares4" foo="four" baz="whocares5"></td>

Desired ending text, in which all foo="..." attributes/values are moved to the beginning of their respective <td> tag):

	<td foo="one"></td>
	<td bar="whocares1"></td>
	<td foo="two" bar="whocares2"></td>
	<td foo="three" bar="whocares3"></td>
	<td foo="four" bar="whocares4" baz="whocares5"></td>

Note that the first three rows will remain unchanged; they are just there to make the exact set of keystrokes more difficult to write :)

In TextPad, I'd start by placing the cursor at the beginning of the first line. Start recording macro. Then I'd type [comments in square brackets explain what the keystrokes do]:

Ctrl+F [open "Find" dialog box]
foo=" [string I'm searching for; then hit Enter to make it find the next one]
Ctrl+F [open "find" dialog box again]
" [to search for the closing quote; and check the "Extend Selection checkbox in the Find dialog box (a feature VSCode doesn't seem to have, but that's not really the point of this exercise); then hit Enter to make it find the closing quote and extend the selection to be foo="..."]
At this point, it has highlighted foo="..." (i.e. with a leading space.) Then:
Ctrl+X [to cut that chunk of text]
Home [to move the cursor to the first non-whitespace char at the start of that line, meaning just to the left of the <td>]
RightArrow three times [to put the cursor just past the "d" in <td]
Ctrl+V to paste [pastes foo="..." just after the <td so we now have <td foo="..."]
DownArrow [to move to the next line]
Home [to move to the beginning of that line]

Stop recording. Playback (preferably via a single keystroke) until all text has been changed.

Note that individual keystrokes inside the Find dialog box are not recorded; it just records the results of performing the search.

Admittedly this is a bit complex because the macro involves using the Find dialog box, but being able to do so just makes the macro feature all the more powerful if you ask me.

I'm sure there's a clever way to accomplish this with rexegps but that's just not worth the brain damage when a macro is so much easier. And even if you could do it, VSCode doesn't give you a way to label/search/sort/organize search-and-replace sequences, so in reality VSCode's regexps are really only useful as throwaway, one-time solutions.

Another thing I use macros for is selectively finding chunks of text and extracting/moving them to another part of the file. I'll see if I can come up with an example and post it in another comment.