| 646 | } |
| 647 | |
| 648 | void BreakpointModel::toggleBreakpoint(const QUrl& url, const KTextEditor::Cursor& cursor) |
| 649 | { |
| 650 | Q_D(BreakpointModel); |
| 651 | |
| 652 | Breakpoint *b = breakpoint(url, cursor.line()); |
| 653 | if (b) { |
| 654 | removeBreakpoint(b); |
| 655 | } else { |
| 656 | // We forbid adding breakpoints to an untitled/unsaved document by not enabling its breakpoint actions. |
| 657 | // The Toggle Breakpoint action is always enabled though, hence the check and early-return below. |
| 658 | const auto* const documentController = ICore::self()->documentController(); |
| 659 | const auto* const doc = documentController ? documentController->documentForUrl(url) : nullptr; |
| 660 | const auto* const textDocument = doc ? doc->textDocument() : nullptr; |
| 661 | if (textDocument && !(textDocument->editableMarks() & BreakpointMark)) { |
| 662 | // Discard the previous message (if any) to prevent stacking of identical messages, |
| 663 | // which the user must dismiss one by one. |
| 664 | delete d->noBreakpointsInUntitledDocumentMessage.data(); |
| 665 | |
| 666 | auto* const message = new Sublime::Message( |
| 667 | i18n("A breakpoint cannot be added to an untitled document. Please save the document first."), |
| 668 | Sublime::Message::Error); |
| 669 | ICore::self()->uiController()->postMessage(message); |
| 670 | d->noBreakpointsInUntitledDocumentMessage = message; |
| 671 | return; |
| 672 | } |
| 673 | |
| 674 | addCodeBreakpoint(url, cursor.line()); |
| 675 | } |
| 676 | } |
| 677 | |
| 678 | void BreakpointModel::reportChange(Breakpoint* breakpoint, Breakpoint::Column column) |
| 679 | { |
nothing calls this directly
no test coverage detected