| 2649 | } |
| 2650 | |
| 2651 | void CodeEdit::duplicate_selection() { |
| 2652 | begin_complex_operation(); |
| 2653 | begin_multicaret_edit(); |
| 2654 | |
| 2655 | // Duplicate lines from carets without selections first. |
| 2656 | for (int i = 0; i < get_caret_count(); i++) { |
| 2657 | if (multicaret_edit_ignore_caret(i)) { |
| 2658 | continue; |
| 2659 | } |
| 2660 | for (int l = get_selection_from_line(i); l <= get_selection_to_line(i); l++) { |
| 2661 | unfold_line(l); |
| 2662 | } |
| 2663 | if (has_selection(i)) { |
| 2664 | continue; |
| 2665 | } |
| 2666 | |
| 2667 | String text_to_insert = get_line(get_caret_line(i)) + "\n"; |
| 2668 | // Insert new text before the line, so the caret is on the second one. |
| 2669 | insert_text(text_to_insert, get_caret_line(i), 0); |
| 2670 | } |
| 2671 | |
| 2672 | // Duplicate selections. |
| 2673 | for (int i = 0; i < get_caret_count(); i++) { |
| 2674 | if (multicaret_edit_ignore_caret(i)) { |
| 2675 | continue; |
| 2676 | } |
| 2677 | if (!has_selection(i)) { |
| 2678 | continue; |
| 2679 | } |
| 2680 | |
| 2681 | // Insert new text before the selection, so the caret is on the second one. |
| 2682 | insert_text(get_selected_text(i), get_selection_from_line(i), get_selection_from_column(i)); |
| 2683 | } |
| 2684 | |
| 2685 | end_multicaret_edit(); |
| 2686 | end_complex_operation(); |
| 2687 | } |
| 2688 | |
| 2689 | void CodeEdit::duplicate_lines() { |
| 2690 | begin_complex_operation(); |
no outgoing calls
no test coverage detected