feat: Emacs kill-ring — CutToEndOfLine / CutToStartOfLine with consecutive-kill append#154
Conversation
Implement Emacs-style kill commands: - CutToEndOfLine: delete caret→EOL (or newline if at EOL) - CutToStartOfLine: delete BOL→caret - Consecutive kills append/prepend to clipboard (kill-ring) - Unbound by default; bindable via Editor.DefaultKeyBindings config - 13 integration tests covering kill, undo, append, and break-run Agent-Logs-Url: https://github.com/gui-cs/Editor/sessions/f496a365-fb5d-4ff1-b62c-4d7a93b2a59a Co-authored-by: tig <585482+tig@users.noreply.github.com>
Agent-Logs-Url: https://github.com/gui-cs/Editor/sessions/f496a365-fb5d-4ff1-b62c-4d7a93b2a59a Co-authored-by: tig <585482+tig@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f12bed4ac2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 019b0e943d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@copilot see cr feedback and address |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fbd4929f6f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…append Snapshot _lastCommandWasKill into _previousCommandWasKill before clearing, so kill commands can read whether the preceding command was a kill. Two snapshot sites cover both dispatch paths: - OnKeyDown (keyboard dispatch) - Each kill command entry (InvokeCommand dispatch) Agent-Logs-Url: https://github.com/gui-cs/Editor/sessions/017298b2-f383-474b-92a5-ea7d1551be45 Co-authored-by: tig <585482+tig@users.noreply.github.com>
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Fixed in |
There was a problem hiding this comment.
Pull request overview
Adds Emacs-style kill-to-line-boundary commands to Editor, with clipboard accumulation semantics for consecutive kills and documentation/tests for the behavior.
Changes:
- Registers
CutToEndOfLine/CutToStartOfLinecommands without default key bindings. - Adds kill-run state tracking and clipboard append/prepend logic.
- Adds integration tests and a feature spec for kill-ring behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
src/Terminal.Gui.Editor/Editor.cs |
Adds kill-ring state fields. |
src/Terminal.Gui.Editor/Editor.Keyboard.cs |
Tracks kill-run state around keyboard dispatch. |
src/Terminal.Gui.Editor/Editor.Commands.cs |
Registers and implements kill-to-EOL/BOL commands and clipboard writes. |
tests/Terminal.Gui.Editor.IntegrationTests/EditorKillRingTests.cs |
Adds integration tests for kill commands and bindings policy. |
specs/kill-ring/spec.md |
Documents command behavior and binding policy. |
Comments suppressed due to low confidence (1)
tests/Terminal.Gui.Editor.IntegrationTests/EditorKillRingTests.cs:171
- This consecutive-kill coverage uses
InvokeCommand, so it exercises only the direct command path. Because the implementation has separateOnKeyDownsnapshot logic for keyboard dispatch, add a test that temporarily binds a key to the kill command and usesInjectKeyfor two consecutive kills; otherwise the user opt-in key-binding path can regress independently.
fx.Top.Editor.InvokeCommand (Command.CutToEndOfLine);
Assert.Equal ("\ndef\nghi", fx.Top.Editor.Document?.Text);
// Second kill (consecutive): "\n" → clipboard = "abc\n"
fx.Top.Editor.InvokeCommand (Command.CutToEndOfLine);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot address CR feedback |
… leak, add clipboard-failure tests, fix prepend test, remove unused usings, update spec Agent-Logs-Url: https://github.com/gui-cs/Editor/sessions/d3cdb4ab-2c70-4881-acd3-299f9a1ad336 Co-authored-by: tig <585482+tig@users.noreply.github.com>
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
All six CR items addressed in
All 239 integration + 461 unit tests pass. Formatting clean. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b2774772a5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Editorlacks Emacs-style line-boundary kill commands where consecutive kills accumulate on the clipboard.TextViewships these viaCommand.CutToEndOfLine/Command.CutToStartOfLine;Editoronly has selection-basedCut/Copy/Paste.Commands
CutToEndOfLine— caret→EOL, or kills the line delimiter if already at EOL (joining lines). Consecutive kills append.CutToStartOfLine— BOL→caret. Consecutive kills prepend (preserving document order).RunUpdate(), no-op whenReadOnly, consume selection if present, abort without modifying document if clipboard write fails.Kill-ring state
Two fields track the consecutive-kill run:
_lastCommandWasKill— set totrueby kill commands after executing._previousCommandWasKill— set byOnKeyDownas a snapshot of_lastCommandWasKillbefore clearing it, so the dispatched kill command can read whether the preceding command was a kill.Kill commands use
consecutiveKill = _previousCommandWasKill || _lastCommandWasKillto cover both dispatch paths:OnKeyDown): reads_previousCommandWasKill(snapshotted before clearing)._previousCommandWasKillis cleared after dispatch returns to prevent stale flag leaks into subsequentInvokeCommandcalls.InvokeCommanddispatch: reads_lastCommandWasKilldirectly (sinceOnKeyDownis bypassed).Any intervening non-kill command breaks the run: keyboard commands go through
OnKeyDownwhich clears the flag; programmaticInvokeCommandof non-kill commands is a documented limitation.Binding policy
Unbound by default — no entry in
DefaultKeyBindings. Users opt in via[ConfigurationProperty] Editor.DefaultKeyBindingsconfig.Tests
16 integration tests: boundary kills, delimiter kills, end-of-document no-op, single undo, read-only guard, consecutive-kill append/prepend (including cross-line prepend), non-kill command breaking the run, unbound-by-default assertion, selection-consumed behavior, and clipboard-failure preservation for both commands.
Spec
specs/kill-ring/spec.mddocuments commands, append/prepend semantics, dual-path flag logic, and binding policy.