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

Feature request: stateful commands? #27

Open
zhaojiangbin opened this issue Jul 11, 2021 · 0 comments
Open

Feature request: stateful commands? #27

zhaojiangbin opened this issue Jul 11, 2021 · 0 comments

Comments

@zhaojiangbin
Copy link

First of all, thanks for this wonderful extension.

Say I want to define a command for the 'v' key, that, depending on how many time I press the key in a row, the command shows the current line at the top, center, bottom of the editor pane, respectively.

For example, on the first press of 'v', the command brings the current line to the top. If I press the 'v' key again, it brings the current line to the center. Then on the third press, the line is at the bottom. Pressing the key again, the line goes to the top, so on and so forth.

Right now I have to define three commands like below:

        "v": {
            "help": "Show current line at [C]enter/[T]op/[B]ottom"
            "c": {
                "command": "revealLine",
                "args": "{ lineNumber: __line, at: 'center' }"
            },
            "t": {
                "command": "revealLine",
                "args": "{ lineNumber: __line, at: 'top' }"
            },
            "b": {
                "command": "revealLine",
                "args": "{ lineNumber: __line, at: 'bottom' }"
            }
        },

But it would be better if I can just keep pressing the same key, 'v', to cycle through the three positions.

I'd imagine for such commands to work they will need to carry a state hence the issue's subject "stateful commands".

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