MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / duplicate_lines

Method duplicate_lines

scene/gui/code_edit.cpp:2689–2711  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2687}
2688
2689void CodeEdit::duplicate_lines() {
2690 begin_complex_operation();
2691 begin_multicaret_edit();
2692
2693 Vector<Point2i> line_ranges = get_line_ranges_from_carets(false, false);
2694 int line_offset = 0;
2695 for (Point2i line_range : line_ranges) {
2696 // The text that will be inserted. All lines in one string.
2697 String text_to_insert;
2698
2699 for (int i = line_range.x + line_offset; i <= line_range.y + line_offset; i++) {
2700 text_to_insert += get_line(i) + "\n";
2701 unfold_line(i);
2702 }
2703
2704 // Insert new text before the line.
2705 insert_text(text_to_insert, line_range.x + line_offset, 0);
2706 line_offset += line_range.y - line_range.x + 1;
2707 }
2708
2709 end_multicaret_edit();
2710 end_complex_operation();
2711}
2712
2713/* Visual */
2714Color CodeEdit::_get_brace_mismatch_color() const {

Callers 5

_edit_optionMethod · 0.80
_edit_optionMethod · 0.80
_menu_optionMethod · 0.80
inputMethod · 0.80
test_code_edit.hFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected