Limit infinite recursion in macros
What did you do?
Accidentally wrote a macro with an infinite loop
Put the exact keys you pressed.
qqiexampletextEscq@q
What did you expect to happen?
Expected the macro definition to fail and @q to remain undefined
What happened instead?
Macro got into an infinite loop and required a vscode restart
Technical details:
- VSCode Version: 1.9.1
- VsCodeVim Version: 0.5.2
- OS: 10.12.3
This doesn't seem to be how vim behaves.
It is admittedly kind of bad behavior, but at least for me on neovim, it seems to hang neovim for a long amount of time.
Also, at least for me, it doesn't seem to crash vscode. You can get things working fine again if you switch to another file and then switch back.
I think we could limit macro recursion to a certain depth. That wouldn't hurt anyone. Who writes recursive macros anyways?
Who does indeed? I'm sure somebody will complain though...
Do you think we bother making it a setting? And what's a good value? 10k?
Luckily, we've basically doing tail recursive optimization already :^)
@Chillee can you just use your first commit and limit it to 10k
@xconverge I'll fix it up this weekend.
Ran into this also. Or a shortcut for interrupting ongoing commands.

I write recursive macros! insert favourite movie-villain-esque evil laughter
I like to be able to go:
- Search for specific string
- Operate on string and it's context in a way that means it's no-longer found in the search
- Goto #1
That way I don't have to deal with the accursed demon that is mathematics, or holding down the @ key until my PC sprays a rapid-fire series of dings at me or any of that nonsense. Just "Computer, do this for me till you can't anymore, then stop".
But I do occasionally flub the exit condition, and would love to be able to explicitly STOP a macro (ie: #3273) regardless of it's depth of recursion because I KNOW from how I'm seeing it behave that I've done wrong.
I've seen somewhere that switching to a new tab will do it, and that seems to work okay in the short amount of time I've been testing it, but it would be really nice if Ctrl+C worked the same way as it does in VIM, because that's my exact reflexive response and it took me a significant amount of googling to find the tab-switch trick.
That said, if recursion limit is definitely going to be a thing, please make it configurable or opt-out or something! Don't take my lazy away please!
In particular I've noticed that if the macro contains a 'search' in Vim that fails to find a result, the macro will terminate, while in VSCode it seems to not. Not sure if that's already an issue somewhere though, but that could help with unexpected recursion quite a bit.