feat(editor): retain cuts in a kill ring with yank-pop - #181
Merged
Conversation
Greptile SummaryThis PR replaces the single cut slot with a process-local 32-entry kill ring and adds yank-pop cycling.
Confidence Score: 4/5The implementation appears behaviorally safe, but the roadmap must be updated to satisfy the repository’s documentation-alignment requirement before merging. Kill-ring retention, yank-pop routing, stale-state validation, Unicode-aware replacement, and undo behavior are coherently implemented and tested; the only accepted issue is the stale status of issue #47 in two roadmap entries. Files Needing Attention: docs/roadmap.md
|
| Filename | Overview |
|---|---|
| src/app.rs | Adds kill-ring ownership, validated yank state, yank-pop replacement, invalidation paths, and extensive behavioral tests. |
| src/kill_ring.rs | Implements a newest-first deque retaining at most 32 complete nonempty cuts. |
| src/command_registry.rs | Registers yank-pop as a named editor command. |
| src/commands.rs | Adds YankPop to the command model and dispatch integration. |
| src/keymap.rs | Maps Meta-y to the new yank-pop command. |
| docs/roadmap.md | Closes issue #166 but leaves both entries for the newly delivered #47 feature marked open. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
K[Kill region or line] --> R[Push nonempty text to 32-entry ring]
Y[C-y / yank] --> N[Insert newest entry]
N --> S[Record buffer, revision, range, point, ring index]
P[M-y / yank-pop] --> V{State still valid?}
V -->|No| E[Report invalid yank-pop]
V -->|Yes| O[Select next older entry]
O --> X[Replace exact prior inserted range]
X --> S
C[Movement, edit, save, history, or buffer change] --> I[Invalidate yank state]
Reviews (1): Last reviewed commit: "feat(editor): retain cuts in a kill ring..." | Re-trigger Greptile
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.
Cortex now retains the last 32 nonempty cuts. C-y inserts the newest, and M-y or the named yank-pop command cycles through older entries, replacing only the previous yank. Movement, edits, save, buffer changes, and history commands invalidate that replacement.
Yank state checks buffer identity, revision, point, and the exact inserted character range. This preserves neighboring text when combining marks, regional indicators, or zero-width joiners make a yank merge with adjacent graphemes. Each kill, yank, and yank-pop remains independently undoable.
Validation: formatting, strict all-target Clippy, release build, 378 unit tests, and 11 of 13 terminal integration tests pass locally. The two existing redirected-input tests remain sandbox-restricted and require macOS CI. A release PTY session passed multiple line and region kills, C-y/M-y cycling, named yank-pop, undo/redo across saves, movement invalidation, and shell restoration. Fresh independent review approved with no findings.
Closes #47.