| 498 | } |
| 499 | |
| 500 | void Breakpoint::updateMovingCursor(const QUrl& url, int line) |
| 501 | { |
| 502 | // Can a moving cursor even be enabled? |
| 503 | if (!m_model || line < 0 || url.isEmpty()) { |
| 504 | stopDocumentLineTracking(); |
| 505 | return; |
| 506 | } |
| 507 | |
| 508 | if (m_movingCursor) { |
| 509 | // Cursor is attached already, is it possible to retain it? |
| 510 | auto* const document = m_movingCursor->document(); |
| 511 | if (document && document->url() == url) { |
| 512 | if (line >= document->lines()) { |
| 513 | stopDocumentLineTracking(); |
| 514 | } else if (m_movingCursor->line() != line) { |
| 515 | { |
| 516 | const auto guard = m_model->markChangeGuard(); |
| 517 | document->removeMark(m_movingCursor->line(), BreakpointModel::AllBreakpointMarks); |
| 518 | document->addMark(line, markType()); |
| 519 | } |
| 520 | m_movingCursor->setLine(line); |
| 521 | } |
| 522 | return; |
| 523 | } |
| 524 | } |
| 525 | |
| 526 | // Find the document: |
| 527 | const auto* const documentController = ICore::self()->documentController(); |
| 528 | const auto* const document = documentController ? documentController->documentForUrl(url) : nullptr; |
| 529 | if (document) { |
| 530 | // Either document changed or the breakpoint has no moving cursor yet. |
| 531 | const auto textDocument = document->textDocument(); |
| 532 | if (textDocument && line < textDocument->lines()) { |
| 533 | restartDocumentLineTrackingAt(*textDocument, line); |
| 534 | return; |
| 535 | } |
| 536 | } |
| 537 | |
| 538 | // No document was found, or the location is after the last line of the new document. |
| 539 | stopDocumentLineTracking(); |
| 540 | } |
nothing calls this directly
no test coverage detected