@@ -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+ ---
0 commit comments