Skip to content

feat(editor): retain cuts in a kill ring with yank-pop - #181

Merged
owainlewis merged 1 commit into
mainfrom
codex/issue-47-kill-ring
Sep 8, 2026
Merged

feat(editor): retain cuts in a kill ring with yank-pop#181
owainlewis merged 1 commit into
mainfrom
codex/issue-47-kill-ring

Conversation

@owainlewis

Copy link
Copy Markdown
Owner

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.

@greptile-apps

greptile-apps Bot commented Sep 8, 2026

Copy link
Copy Markdown

Greptile Summary

This PR replaces the single cut slot with a process-local 32-entry kill ring and adds yank-pop cycling.

  • Tracks the exact inserted character range, buffer identity, revision, point, and ring index for safe replacement.
  • Adds Meta-y and named-command routing for yank-pop.
  • Preserves independent undo boundaries for kills, yanks, and yank-pop operations.
  • Adds focused coverage for ordering, eviction, invalidation, Unicode grapheme seams, buffer switching, and saved history baselines.
  • Updates user and architecture documentation, although the [v0.3] Replace cut slot with a real kill ring #47 roadmap statuses remain stale.

Confidence Score: 4/5

The 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

Important Files Changed

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]
Loading

Reviews (1): Last reviewed commit: "feat(editor): retain cuts in a kill ring..." | Re-trigger Greptile

Comment thread docs/roadmap.md
@owainlewis
owainlewis merged commit 8334cb3 into main Sep 8, 2026
2 checks passed
@owainlewis
owainlewis deleted the codex/issue-47-kill-ring branch September 8, 2026 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[v0.3] Replace cut slot with a real kill ring

1 participant