Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/RunButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ async function handleExecution(block: CodeBlockContext) {
const s: ExecutorSettings = block.outputter.settings;

button.className = disabledClass;
block.srcCode = await new CodeInjector(app, s, language).injectCode(srcCode);
// Run against a copy of the block context: the context is shared between
// runs of the same rendered block, so writing the injected code back into
// it would compound pre/post/import injections on every re-run.
block = { ...block, srcCode: await new CodeInjector(app, s, language).injectCode(srcCode) };

switch (language) {
case "js": return runCode(s.nodePath, s.nodeArgs, s.jsFileExtension, block, { transform: (code) => macro.expandJS(code) });
Expand Down