Skip to content

Commit 20550de

Browse files
committed
feat: US-012 - Vim Undo/Redo with History Tree
1 parent 8164914 commit 20550de

4 files changed

Lines changed: 842 additions & 1 deletion

File tree

prd.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@
281281
"Typecheck passes"
282282
],
283283
"priority": 12,
284-
"passes": false,
284+
"passes": true,
285285
"notes": ""
286286
},
287287
{

progress.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,3 +305,30 @@ Thread: http://localhost:8317/threads/T-019bbbe5-fc2f-7144-a068-b3ca0e2e5c48
305305
- recordingMacro state holds current register being recorded, null when not recording
306306
- lastPlayedMacro tracks register for @@ repeat functionality
307307
---
308+
309+
## 2026-01-14 - US-012
310+
Thread: http://localhost:8317/threads/T-019bbbec-4388-7091-8ef6-c243c9e3acfe
311+
- Implemented comprehensive vim undo/redo system in src/lib/simulator/vim/undo.ts:
312+
- u undoes last change via undo(state, count)
313+
- Ctrl-r redoes via redo(state, count)
314+
- Linear undo/redo using existing undoStack/redoStack on VimBuffer
315+
- g- (undoOlderState) and g+ (undoNewerState) for traversing undo tree
316+
- :earlier {time} and :later {time} commands with time parsing (s/m/h/d)
317+
- :undolist via getUndoList() shows undo history with timestamps
318+
- U (undoLineChanges) undoes all changes on current line
319+
- Changes grouped via BufferSnapshot with timestamps
320+
- Implemented dot repeat (.) functionality:
321+
- RepeatableCommand interface stores operator/motion/count/insertedText
322+
- recordOperatorMotionCommand(), recordChangeCommand(), recordInsertCommand(), recordSimpleCommand()
323+
- executeDotRepeat() executes the last recorded command
324+
- Supports operators with motions, change commands, insert commands, simple commands (x, dd, etc.)
325+
- Helper functions: toggleCaseAtCursor, joinLines, indentLine, dedentLine
326+
- Updated src/lib/simulator/vim/index.ts to export undo module
327+
- Files changed: 2 files (undo.ts new, index.ts updated)
328+
- **Learnings for future iterations:**
329+
- undo.ts combines both undo/redo system and dot repeat functionality
330+
- Use updateActiveBuffer helper for consistent buffer state updates
331+
- RepeatableCommand uses JSON.stringify/parse for storing in lastCommand string field
332+
- Time parsing supports seconds (s), minutes (m), hours (h), days (d)
333+
- undoLineChanges attempts to find snapshot where cursor was on same line
334+
---

src/lib/simulator/vim/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ export * from "./search";
88
export * from "./registers";
99
export * from "./marks";
1010
export * from "./macros";
11+
export * from "./undo";

0 commit comments

Comments
 (0)