Undo multiple commands to reach target index. Args: target_index: Index to undo to (must be <= current_index) Returns: List of descriptions of undone commands
(self, target_index: int)
| 255 | logger.warning(f"Removed command due to memory limit: {removed.get_description()}") |
| 256 | |
| 257 | def undo_to_command(self, target_index: int) -> List[str]: |
| 258 | """ |
| 259 | Undo multiple commands to reach target index. |
| 260 | |
| 261 | Args: |
| 262 | target_index: Index to undo to (must be <= current_index) |
| 263 | |
| 264 | Returns: |
| 265 | List of descriptions of undone commands |
| 266 | """ |
| 267 | if target_index > self.current_index or target_index < -1: |
| 268 | return [] |
| 269 | |
| 270 | undone_descriptions = [] |
| 271 | while self.current_index > target_index: |
| 272 | description = self.undo() |
| 273 | if description: |
| 274 | undone_descriptions.append(description) |
| 275 | else: |
| 276 | break |
| 277 | |
| 278 | return undone_descriptions |
| 279 | |
| 280 | |
| 281 | class PerformanceMonitor: |