|
8 | 8 | - When spreading state with null assignments, always add explicit `: VimState` type annotation to avoid TypeScript inference narrowing |
9 | 9 | - Text objects live in src/lib/simulator/vim/textObjects.ts; use executeTextObject(state, type, objectKey) as main entry point |
10 | 10 | - Command mode functions live in src/lib/simulator/vim/commands.ts; use handleCommandModeKey() for key processing, executeCommand() for command execution |
| 11 | +- Macro functions live in src/lib/simulator/vim/macros.ts; use prepareMacroExecution() to get keystrokes array, caller is responsible for executing them |
11 | 12 |
|
12 | 13 | --- |
13 | 14 |
|
@@ -278,3 +279,29 @@ Thread: http://localhost:8317/threads/T-019bbbdf-b4d1-744e-9ee9-9bf0fee9833e |
278 | 279 | - SearchResult type used for all search operations |
279 | 280 | - searchState in VimState tracks pattern, matches, currentMatchIndex, highlightEnabled |
280 | 281 | --- |
| 282 | + |
| 283 | +## 2026-01-14 - US-011 |
| 284 | +Thread: http://localhost:8317/threads/T-019bbbe5-fc2f-7144-a068-b3ca0e2e5c48 |
| 285 | +- Implemented complete vim macro system in src/lib/simulator/vim/macros.ts: |
| 286 | + - q{a-z} starts recording to register via startMacroRecording() |
| 287 | + - q stops recording via stopMacroRecording() |
| 288 | + - Status bar message "recording @{register}" while recording |
| 289 | + - recordKeystroke() captures all keystrokes during recording |
| 290 | + - @{a-z} plays macro via prepareMacroExecution() which returns keystrokes array |
| 291 | + - @@ repeats last played macro using lastPlayedMacro state |
| 292 | + - {count}@{a-z} supported via count parameter in prepareMacroExecution() |
| 293 | + - Macros can call other macros (keystrokes include @ sequences) |
| 294 | + - Macro execution stops on error (caller handles by checking success flag) |
| 295 | + - getMacrosForDisplay() for :registers integration |
| 296 | + - encodeKeystrokeForMacro() handles special keys (<Esc>, <Enter>, <C-x>, etc.) |
| 297 | + - parseMacroKeystrokes() parses encoded sequences back to keystrokes |
| 298 | + - setMacroContent()/appendToMacro() for uppercase register append behavior |
| 299 | +- Updated src/lib/simulator/vim/index.ts to export macros module |
| 300 | +- Files changed: 2 files (macros.ts new, index.ts updated) |
| 301 | +- **Learnings for future iterations:** |
| 302 | + - Macros stored as string in state.macros[register], not as keystroke arrays |
| 303 | + - prepareMacroExecution() returns { state, keystrokes[], success, error? } - caller executes keystrokes |
| 304 | + - Use <Esc>, <Enter>, <C-x> notation for special keys in macro storage |
| 305 | + - recordingMacro state holds current register being recorded, null when not recording |
| 306 | + - lastPlayedMacro tracks register for @@ repeat functionality |
| 307 | +--- |
0 commit comments