| 1752 | } |
| 1753 | |
| 1754 | void CodeTextEditor::toggle_bookmark() { |
| 1755 | Vector<int> sorted_carets = text_editor->get_sorted_carets(); |
| 1756 | int last_line = -1; |
| 1757 | for (const int &c : sorted_carets) { |
| 1758 | int from = text_editor->get_selection_from_line(c); |
| 1759 | from += from == last_line ? 1 : 0; |
| 1760 | int to = text_editor->get_selection_to_line(c); |
| 1761 | if (to < from) { |
| 1762 | continue; |
| 1763 | } |
| 1764 | // Check first if there's any bookmarked lines in the selection. |
| 1765 | bool selection_has_bookmarks = false; |
| 1766 | for (int line = from; line <= to; line++) { |
| 1767 | if (text_editor->is_line_bookmarked(line)) { |
| 1768 | selection_has_bookmarks = true; |
| 1769 | break; |
| 1770 | } |
| 1771 | } |
| 1772 | |
| 1773 | // Set bookmark on caret or remove all bookmarks from the selection. |
| 1774 | if (!selection_has_bookmarks) { |
| 1775 | if (text_editor->get_caret_line(c) != last_line) { |
| 1776 | text_editor->set_line_as_bookmarked(text_editor->get_caret_line(c), true); |
| 1777 | } |
| 1778 | } else { |
| 1779 | for (int line = from; line <= to; line++) { |
| 1780 | text_editor->set_line_as_bookmarked(line, false); |
| 1781 | } |
| 1782 | } |
| 1783 | last_line = to; |
| 1784 | } |
| 1785 | } |
| 1786 | |
| 1787 | void CodeTextEditor::goto_next_bookmark() { |
| 1788 | PackedInt32Array bmarks = text_editor->get_bookmarked_lines(); |
no test coverage detected