Sublime Forum

[test]: simulate key press

#1

Hi!

I’m doing a little plugin to type markdown plugin. One of the feature is that it adds a * when you press * (like the quote), so there’s a bunch of stuff to do with it. So a bunch of test to run.

So, I was wondering if there is a way to simulate a shortcut.. Maybe something like: view.press('*'). So, I could run my test automatically. It would be long, I know, but one I’d have done it, it would be super easy.

The idea is that it takes in consideration the context.

Matt

1 Like

#2

there’s no easy way, but you can read the keybindings, evaluate the contexts to see if they are valid/active and then execute the relevant command referred to in the keybinding, passing in the arguments it specifies, if any.

however, due to the regex engine that is used by Python being different from the one used by the keybinding contexts, and the fact that some contexts are not available to query directly, you may not be able to evaluate some contexts manually, depending which regex features or custom contexts were used. Related feature request/more details:

0 Likes