conductor(checkpoint): Checkpoint end of Phase 4 - UI Features & History List
This commit is contained in:
@@ -112,3 +112,20 @@ class HistoryManager:
|
||||
{"description": e.description, "timestamp": e.timestamp}
|
||||
for e in self._undo_stack
|
||||
]
|
||||
|
||||
def jump_to_undo(self, index: int, current_state: typing.Any, current_description: str = "Before Jump") -> typing.Optional[HistoryEntry]:
|
||||
"""
|
||||
Jumps to a specific state in the undo stack by moving subsequent states
|
||||
and the current_state to the redo stack.
|
||||
"""
|
||||
if index < 0 or index >= len(self._undo_stack):
|
||||
return None
|
||||
|
||||
# Move current state to redo
|
||||
self._redo_stack.append(HistoryEntry(state=current_state, description=current_description))
|
||||
|
||||
# Move states between index and top of undo to redo
|
||||
while len(self._undo_stack) > index + 1:
|
||||
self._redo_stack.append(self._undo_stack.pop())
|
||||
|
||||
return self._undo_stack.pop()
|
||||
|
||||
Reference in New Issue
Block a user