summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-02-19 19:54:24 +0100
committerGitHub <noreply@github.com>2018-02-19 19:54:24 +0100
commit959b3e6d8c6eee37cb8d7ab3be0bc8ada4687b43 (patch)
tree0a547677da8f53eb582cb38e81d2190946ff52cc /editor
parent9130770ec5ed30e399e47c057c3eaaba3d743d5f (diff)
parent7368978a48127a4c238f51bd0dbdf4c8d091809f (diff)
Merge pull request #16752 from Yanpas/dellines
Delete all selected lines using the "delete line" shortcut in script editor
Diffstat (limited to 'editor')
-rw-r--r--editor/plugins/script_text_editor.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 87e92f0807..aeba0ff930 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -935,13 +935,27 @@ void ScriptTextEditor::_edit_option(int p_op) {
Ref<Script> scr = get_edited_script();
if (scr.is_null())
return;
-
tx->begin_complex_operation();
- int line = tx->cursor_get_line();
- tx->set_line(tx->cursor_get_line(), "");
- tx->backspace_at_cursor();
- tx->unfold_line(line);
- tx->cursor_set_line(line);
+ if (tx->is_selection_active()) {
+ int to_line = tx->get_selection_to_line();
+ int from_line = tx->get_selection_from_line();
+ int count = Math::abs(to_line - from_line) + 1;
+ while (count) {
+ tx->set_line(tx->cursor_get_line(), "");
+ tx->backspace_at_cursor();
+ count--;
+ if (count)
+ tx->unfold_line(from_line);
+ }
+ tx->cursor_set_line(from_line - 1);
+ tx->deselect();
+ } else {
+ int line = tx->cursor_get_line();
+ tx->set_line(tx->cursor_get_line(), "");
+ tx->backspace_at_cursor();
+ tx->unfold_line(line);
+ tx->cursor_set_line(line);
+ }
tx->end_complex_operation();
} break;
case EDIT_CLONE_DOWN: {