| 454 | } |
| 455 | |
| 456 | void ZepMode::AddCommand(std::shared_ptr<ZepCommand> spCmd) { |
| 457 | if (m_pCurrentWindow == nullptr) { |
| 458 | return; |
| 459 | } |
| 460 | |
| 461 | if (GetCurrentWindow()->GetBuffer().HasFileFlags(FileFlags::Locked)) { |
| 462 | // Ignore commands on buffers because we are view only, |
| 463 | // and all commands currently modify the buffer! |
| 464 | return; |
| 465 | } |
| 466 | |
| 467 | auto& undoStack = m_pCurrentWindow->GetBuffer().GetUndoStack(); |
| 468 | auto& redoStack = m_pCurrentWindow->GetBuffer().GetRedoStack(); |
| 469 | |
| 470 | spCmd->Redo(); |
| 471 | undoStack.push(spCmd); |
| 472 | |
| 473 | // Can't redo anything beyond this point |
| 474 | std::stack<std::shared_ptr<ZepCommand>> empty; |
| 475 | redoStack.swap(empty); |
| 476 | |
| 477 | if (spCmd->GetCursorAfter().Valid()) { |
| 478 | GetCurrentWindow()->SetBufferCursor(spCmd->GetCursorAfter()); |
| 479 | } |
| 480 | } |
| 481 | |
| 482 | void ZepMode::Redo() { |
| 483 | if (m_pCurrentWindow == nullptr) { |
no test coverage detected