Skip to content

feat(editor): group typing and deletion into bounded undo history - #180

Merged
owainlewis merged 1 commit into
mainfrom
codex/issue-166-undo-groups
Sep 8, 2026
Merged

feat(editor): group typing and deletion into bounded undo history#180
owainlewis merged 1 commit into
mainfrom
codex/issue-166-undo-groups

Conversation

@owainlewis

Copy link
Copy Markdown
Owner

Continuous typing and same-direction character deletion now undo as complete groups. A pause of 750 ms, movement, prompt entry, buffer switching, save, or a deliberate edit ends the group; undo and redo restore its text and point while retaining precise saved-state and changed-line metadata.

History counts inserted and deleted UTF-8 bytes across both stacks, evicts oldest whole groups above 16 MiB, and retains the newest group even if it alone exceeds that limit. New edits discard the redo branch.

The release check also exposed an existing shortcut defect: Crossterm decodes the legacy C-/ and C-_ byte as C-7. That alias now invokes undo, with a PTY regression that failed before the fix.

Validation: formatting, strict all-target Clippy, release build, 371 unit tests, and 11 of 13 terminal integration tests pass locally. The two existing redirected-input cases remain sandbox-restricted and require the macOS CI run. The release PTY session passed grouped typing, pause and movement boundaries, both deletion directions, undo/redo across saves, and shell restoration. Fresh independent review approved the implementation and shortcut fix.

Closes #166.

@greptile-apps

greptile-apps Bot commented Sep 8, 2026

Copy link
Copy Markdown

Greptile Summary

This PR introduces bounded, grouped undo and redo behavior for continuous typing and same-direction character deletion.

  • Groups edits using explicit timestamps, cursor continuity, edit kind, and deliberate command boundaries.
  • Retains per-edit history identity and changed-line transitions while undoing or redoing complete groups.
  • Tracks inserted and deleted UTF-8 payloads across both history stacks and evicts oldest whole groups above the configured budget.
  • Adds the Crossterm Ctrl-7 alias for the legacy undo control byte and exercises it through a PTY test.
  • Updates user and architecture documentation, although the roadmap closes the wrong issue.

Confidence Score: 4/5

The implementation appears safe to merge, with a non-blocking roadmap status correction recommended.

Group construction, history ordering, byte accounting, eviction, command boundaries, buffer activation, and terminal shortcut behavior are internally consistent and covered by focused tests; the only accepted issue is incorrect roadmap bookkeeping.

Files Needing Attention: docs/roadmap.md

Important Files Changed

Filename Overview
src/buffer.rs Implements grouped history, per-edit state transitions, UTF-8 payload accounting, whole-group eviction, and focused correctness tests.
src/commands.rs Classifies grouping commands, injects timestamps into dispatch, and routes typing and character deletion through grouped buffer operations.
src/app.rs Ends active groups at command, prefix, prompt, paste, and deliberate-action boundaries.
src/editor.rs Ends groups in both outgoing and incoming buffers during activation.
src/keymap.rs Maps Crossterm's Ctrl-7 decoding of the legacy control byte to undo.
tests/signal_cleanup.rs Adds a PTY regression covering the legacy undo byte, grouped typing, save behavior, exit, and terminal restoration.
docs/roadmap.md Incorrectly marks unrelated issue #165 closed while the implemented issue #166 remains open.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Editor input] --> B{Grouping command?}
  B -->|Printable insert| C[Typing group]
  B -->|Backward delete| D[Backward deletion group]
  B -->|Forward delete| E[Forward deletion group]
  B -->|Movement, prompt, save, switch, or deliberate edit| F[End active group]
  C --> G{Same kind, contiguous point, pause under 750 ms?}
  D --> G
  E --> G
  G -->|Yes| H[Append edit to current group]
  G -->|No| I[Create new history group]
  H --> J[Clear redo and enforce payload budget]
  I --> J
  J --> K[Evict oldest complete groups]
  K --> L[Always retain newest group]
  M[Undo] --> N[Apply newest group in reverse order]
  N --> O[Push edits onto redo stack]
  P[Redo] --> Q[Apply selected group in forward order]
  Q --> R[Return edits to undo stack]
Loading

Reviews (1): Last reviewed commit: "feat(editor): group typing and deletion ..." | Re-trigger Greptile

Comment thread docs/roadmap.md
@owainlewis
owainlewis merged commit ba31366 into main Sep 8, 2026
2 checks passed
@owainlewis
owainlewis deleted the codex/issue-166-undo-groups branch September 8, 2026 18:55
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.

Group ordinary typing and deletion into useful undo steps

1 participant