diff options
| author | Paulb23 | 2016-05-19 15:32:41 +0100 |
|---|---|---|
| committer | Rémi Verschelde | 2016-06-04 22:20:02 +0200 |
| commit | e95eb4b1dc1f78c25dfa0519d60acf57d692fade (patch) | |
| tree | 6f4820d9de3cd2da991b38a42a4162e6aa10f756 /tools/editor/plugins/script_editor_plugin.cpp | |
| parent | 01bdfa4d22581d3977f00a8b3e65367cc2767ca3 (diff) | |
| download | godot-e95eb4b1dc1f78c25dfa0519d60acf57d692fade.tar.gz godot-e95eb4b1dc1f78c25dfa0519d60acf57d692fade.tar.zst godot-e95eb4b1dc1f78c25dfa0519d60acf57d692fade.zip | |
Multiline duplication, issue #4661
(cherry picked from commit 2eb4e7c103793c7ca915b5f1cfc1a8bf356c0152)
Diffstat (limited to '')
| -rw-r--r-- | tools/editor/plugins/script_editor_plugin.cpp | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index 4c8e0d1e0..1d06a9fc0 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -1252,16 +1252,35 @@ void ScriptEditor::_menu_option(int p_option) { Ref<Script> scr = current->get_edited_script(); if (scr.is_null()) return; - int line = tx->cursor_get_line(); - int next_line = line + 1; + + int from_line = tx->cursor_get_line(); + int to_line = tx->cursor_get_line(); int column = tx->cursor_get_column(); - if (line >= tx->get_line_count() - 1) - tx->set_line(line, tx->get_line(line) + "\n"); + if (tx->is_selection_active()) { + from_line = tx->get_selection_from_line(); + to_line = tx->get_selection_to_line(); + column = tx->cursor_get_column(); + } + int next_line = to_line + 1; + + tx->begin_complex_operation(); + for (int i = from_line; i <= to_line; i++) { + + if (i >= tx->get_line_count() - 1) { + tx->set_line(i, tx->get_line(i) + "\n"); + } + String line_clone = tx->get_line(i); + tx->insert_at(line_clone, next_line); + next_line++; + } - String line_clone = tx->get_line(line); - tx->insert_at(line_clone, next_line); tx->cursor_set_column(column); + if (tx->is_selection_active()) { + tx->select(to_line + 1, tx->get_selection_from_column(), next_line - 1, tx->get_selection_to_column()); + } + + tx->end_complex_operation(); tx->update(); } break; |
