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

When modifying code in cell with preexecution hook, old code is executed #1131

Closed
ajwheeler opened this issue Nov 7, 2024 · 1 comment
Closed

Comments

@ajwheeler
Copy link

As I understand it, the only way to programmatically modify code is with IJulia.load_string. It seems that if a function using this is registered as a preexecution hook, it modifies the cell as expected, but only after running the unmodified code. JupyterFormatter is where I first noticed this behavior, and it's source is a nearly minimal example of the workflow I'm describing.

It would be really nice to be able to modify the code, and then execute it immediately, without running the cell twice. Is this possible, or it is a limitation of the way Jupyter works?

@stevengj
Copy link
Member

stevengj commented Nov 7, 2024

It's the way Jupyter works — it sends us the code to be executed, at which point we execute the hooks, but at that point it has already sent us the old code.

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

2 participants