( entry: EditHistoryEntry, direction: EditHistoryDirection, currentHashes: Record<string, string>, )
| 148 | } |
| 149 | |
| 150 | export function canApplyEditHistoryEntry( |
| 151 | entry: EditHistoryEntry, |
| 152 | direction: EditHistoryDirection, |
| 153 | currentHashes: Record<string, string>, |
| 154 | ): EditHistoryApplyCheck { |
| 155 | for (const [path, snapshot] of Object.entries(entry.files)) { |
| 156 | const expected = direction === "undo" ? snapshot.afterHash : snapshot.beforeHash; |
| 157 | if (currentHashes[path] !== expected) { |
| 158 | return { ok: false, reason: "content-mismatch", path }; |
| 159 | } |
| 160 | } |
| 161 | return { ok: true }; |
| 162 | } |
| 163 | |
| 164 | export function undoEditHistory( |
| 165 | state: EditHistoryState, |
no test coverage detected