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

Replaying a macro while it is being recorded hangs the page #177

Open
veluca93 opened this issue May 21, 2024 · 3 comments
Open

Replaying a macro while it is being recorded hangs the page #177

veluca93 opened this issue May 21, 2024 · 3 comments

Comments

@veluca93
Copy link

veluca93 commented May 21, 2024

Minimal repro:

import {EditorView, basicSetup} from "codemirror"
import {vim} from "@replit/codemirror-vim"
let editor : EditorView = new EditorView({
  extensions: [vim(), basicSetup, solarizedDark],
  parent: document.body
})

In the resulting editor, typing qaihello<ESC>@a instantly hangs the page, without any obvious way to recover that I could find.

The behaviour in (neo)vim is somewhat better - qaihello<ESC>@a creates an infinite loop of writing hello - but I feel like even that behaviour would be problematic in a web environment, as the user doesn't have a way to interact with the page once this happens.

@nightwing
Copy link
Collaborator

Currently we rely on maximum call stack size exceptions, so @A repeats the macro 512 times.

Unfortunately performance of the extension on v6 is worse than v5, so repeating macro 500 times takes about a minute.
Aside from fixing performance issue, should we also always prevent macro recursion, or can that be useful in some situations and keeping behavior from https://codemirror.net/5/demo/vim.html is ok?

@veluca93
Copy link
Author

I admit I didn't expect that repeating the macro 500 times would lock up the page this badly :-)

I can't at the moment think of a usecase where macro recursion would be useful, but IMO it's best to stick to the vim behaviour if possible (i e. Allow recursion)

@Opisek
Copy link
Contributor

Opisek commented Jun 7, 2024

For the case of tail-recursion, so playing the macro at the end of recording, we could avoid using a call stack entirely. This would also extend to mutually-recursive recordings like qa@bqqb@aq.

If the recursive call takes place in the middle of a recording then it's down to classic optimizations.

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

3 participants