Add 'Run code block under cursor' command#452
Open
nelsonlove wants to merge 7 commits into
Open
Conversation
…en the code block can't be located Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… render, not per execution Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ion start Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… completion Locates the block via the post-processor's getSectionInfo when available, falling back to matching the block's source text. Works in reading view, live preview, and for run- prefixed blocks; re-running replaces the output block instead of appending. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…output; hide live element once saved Reading view used to hide saved ```output blocks via CSS (a workaround for the old streaming write). Now that output is written once on completion, the saved block IS the result display — render it in all views, insert it with a blank line after the code block, and hide the ephemeral on-screen output element once the note has been updated. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Runs the fenced block containing the editor cursor (like org-babel's C-c C-c) through the normal execution pipeline with a detached outputter; results are saved into the note via persistent output. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
An editor command (like org-babel's
C-c C-c/ Jupyter's Ctrl-Enter): put the cursor anywhere inside a fenced code block in source mode or live preview and run it — no need to switch to reading view or hunt for the run button (which doesn't render in live preview while the cursor is inside the block). Output is saved into the note below the block via persistent output.Builds on #449 (whose commits are included) — the buffered
Vault.processpersistent output is what lets this work without any rendered DOM.Implementation
runBlockUnderCursor.ts: tracks fence state from the top of the note to the cursor to find the enclosing block (handles the cursor sitting on either fence line), resolves the language from the fence info string (includingrun-prefixes and{...}args), and dispatches through the existinghandleExecutionwith a detached outputter element.handleExecutionandCodeBlockContextare exported fromRunButton.ts; no behavior change for the button path.editorCallback, so the command only offers itself when an editor is active.Testing
npm run buildpasseslispblock in source mode → command executes it and writes/replaces the ```output block below; works with session (interactive) executors and therun-prefix; Notices for cursor-outside-block, unterminated fences, and non-executable languages🤖 Generated with Claude Code