Add Emacs-style send-to-REPL commands with keybindings - #19
Open
d-torrance wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds six Emacs-style send-to-REPL commands (line, region, buffer, above, below, paragraph) with Ctrl+C-prefixed chord keybindings, and introduces a 300 ms range flash highlight to all send operations. A pure getParagraphLineRange helper implements Emacs-style paragraph boundary detection and is covered by 11 new unit tests.
Changes:
- New
executeLine/Region/Buffer/Above/Below/ParagraphInWebviewfunctions plus a sharedflashRangehelper insrc/backend/repl.ts, with corresponding command registrations and decoration cleanup indeactivate. - New command and chord keybinding contributions in
package.json(six new commands, all bound undereditorTextFocus && editorLangId == macaulay2). - Exported
getParagraphLineRangeand a new "Send Paragraph to REPL" test suite covering 11 boundary cases.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/backend/repl.ts | Adds six new send commands, the flashRange decoration helper, the exported getParagraphLineRange helper, command registrations, and decoration disposal on deactivate. Refactors existing send-to-terminal/webview to use range-based highlighting. |
| package.json | Adds six new macaulay2.send*ToREPL command contributions and ctrl+c-prefixed chord keybindings scoped to Macaulay2 editors. |
| src/backend/test/extension.test.ts | Imports getParagraphLineRange and adds an 11-case suite covering paragraph boundary detection (mid-paragraph, blank lines, top/bottom of file, all-blank buffer, etc.). |
Comments suppressed due to low confidence (1)
src/backend/repl.ts:868
executeSelectionInTerminalandexecuteSelectionInWebviewnow always executecursorMove"down" after sending, including when a multi-line selection is active. Previously (via the removedgetSelectedM2Codepath), Shift+Enter / Ctrl+Enter with a selection did not move the cursor. Moving the cursor down by one line after the user has selected a region is unexpected and changes the long-standing behavior of these existing keybindings. Consider only advancing the cursor when the selection is empty (i.e., the "send current line" path), matching Emacsforward-linesemantics, e.g. wrap thecursorMovecall inif (selection.isEmpty) { ... }.
executeCodeInTerminal(editor.document.getText(range));
vscode.commands.executeCommand("cursorMove", {
to: "down",
by: "line",
value: 1,
});
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Adds six commands mirroring the Macaulay2 Emacs major mode, each sending a different slice of the editor to the M2 REPL: C-c C-j sendLineToREPL current line (advances cursor) C-c C-r sendRegionToREPL active selection C-c C-b sendBufferToREPL entire document C-c C-up sendAboveToREPL everything from start to cursor C-c C-down sendBelowToREPL everything from cursor to end C-c C-p sendParagraphToREPL current paragraph (advances past it) Paragraph detection follows Emacs forward/backward-paragraph semantics: blank lines are delimiters; cursor on a blank line targets the next paragraph below, falling back to the previous one if only whitespace remains below. The paragraph boundary logic is extracted into getParagraphLineRange, a pure exported function covered by 11 unit tests. All send commands (including the existing sendToWebview/sendToTerminal) briefly highlight the exact range being sent for 300 ms using editor.selectionHighlightBackground. The flash is suppressed when editor.renderLineHighlight is "none" or "gutter". Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
d-torrance
force-pushed
the
send-to-program
branch
from
May 29, 2026 22:37
8d9ad15 to
4692945
Compare
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.
Adds six commands mirroring the Macaulay2 Emacs major mode, each sending a different slice of the editor to the M2 REPL:
Paragraph detection follows Emacs
forward-paragraph/backward-paragraphsemantics: paragraphs are delimited by blank lines. When the cursor is on a blank line, the next paragraph below is targeted; if only whitespace remains below, the previous paragraph above is used instead.All send commands (including the existing Shift+Enter / Ctrl+Enter bindings) briefly highlight the range being sent for 300 ms using the
editor.selectionHighlightBackgroundtheme color. The flash is suppressed wheneditor.renderLineHighlightis"none"or"gutter", respecting the user's existing editor highlight preferences.The paragraph boundary logic is extracted into a pure exported function
getParagraphLineRange, covered by 11 unit tests.Edit: An earlier iteration of this PR added Emacs-like keybindings for each of these functions, but they were later removed.
AI Disclosure
This was all Claude