feat(editor): group typing and deletion into bounded undo history - #180
Merged
Conversation
Greptile SummaryThis PR introduces bounded, grouped undo and redo behavior for continuous typing and same-direction character deletion.
Confidence Score: 4/5The 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
|
| 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]
Reviews (1): Last reviewed commit: "feat(editor): group typing and deletion ..." | 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.
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.