Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feasibility study: Can we use 'runCommands' command to implement our macro playback? #242

Closed
tshino opened this issue Apr 27, 2023 · 4 comments

Comments

@tshino
Copy link
Owner

tshino commented Apr 27, 2023

In VS Code 1.77, a new command runCommands has been introduced.
microsoft/vscode#871 (comment)

As far as I know, this command is the first official support for the functionality to execute multiple commands sequentially.

That command may be able to be used to implement our macro playback command in a much simpler and more reliable way and may remove the need for the troublesome await parameters.

I want to know especially:

  • whether it works correctly with commands that didn't work correctly by our playback command without await options
  • whether it can be used recursively, or safely it can detect accidental recursion.
@tshino
Copy link
Owner Author

tshino commented Aug 19, 2023

Experiment 1: Can it run extension commands synchronously?

    {
        "key": "ctrl+p",
        "command": "runCommands",
        "args": {
            "commands": [
                {
                    "command": "type",
                    "args": {
                        "text": "begin!\n"
                    }
                },
                {
                    "command": "kb-macro.playback"
                },
                {
                    "command": "type",
                    "args": {
                        "text": "end!\n"
                    }
                }
            ]
        }
    },

Result: Yes (as far as I tested)

I tested this command sequence with some recorded macro, and it runs expectedly.

@tshino
Copy link
Owner Author

tshino commented Aug 19, 2023

Experiment 2: Can it run runCommands itself as a part of a sequence?

    {
        "key": "ctrl+p",
        "command": "runCommands",
        "args": {
            "commands": [
                {
                    "command": "runCommands",
                    "args": {
                        "commands": [
                            { "command": "editor.action.addCommentLine" }
                        ]
                    }
                }
            ]
        }
    },

Result: Yes (as far as I tested)

Above sequence runs expectedly.

@tshino
Copy link
Owner Author

tshino commented Aug 19, 2023

Experiment 3: Does it handle keyboard autorepeat?

Result: No.

Using the sequence from experiment 1, with some long macro, long pressing ctrl+p gives a broken result.
It also happens even when you hit the key multiple times quickly.

Example result (single press):

begin!
std::cout << "Hello, world!" << std::endl;
end!

Example result (long press):

begin!
std::cout << "Hello, world!" << std::endl;
end!
begin!
std::cout << "Hello, world!" << std::endl;
end!
begin!
std::cout << "Hello, world!" << sdbegin!end!
end!
begin!
std::cout << "Hello, world!" << sd::begin!end!

begin!
std::cout << "ebegin!
end!

end!

"begin!

begin!end!
end!

This behavior would not be acceptable for users who use macros heavily.

@tshino
Copy link
Owner Author

tshino commented Feb 17, 2024

Unfortunately, the feature request to fix the above autorepeat issue has been closed because it has received less than 20 community upvotes.
As a result, it is now clear that runCommands command won't be able to be used as an alternative of our macro playback command kb-macro.playback.

Can we use 'runCommands' command to implement our macro playback?
The answer is No.
I have to continue maintaining this extension.

@tshino tshino closed this as completed Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant