summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorkobewi <kobewi4e@gmail.com>2023-02-21 21:28:26 +0100
committerkobewi <kobewi4e@gmail.com>2023-02-21 21:28:26 +0100
commit5906d6de8e3be3846a0fdc151aab43fea5764d2b (patch)
treece018a0729a04dd4392bed73c22111906c38bb6e /editor
parent253396ba3933b3c1b5a91016ac3eb1fb90788a9d (diff)
Fix line folding with multiple carets
Diffstat (limited to 'editor')
-rw-r--r--editor/plugins/script_text_editor.cpp9
-rw-r--r--editor/plugins/text_editor.cpp9
2 files changed, 14 insertions, 4 deletions
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 5e70a407dd..c1a5283662 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -1225,8 +1225,13 @@ void ScriptTextEditor::_edit_option(int p_op) {
code_editor->duplicate_selection();
} break;
case EDIT_TOGGLE_FOLD_LINE: {
- for (int caret_idx = 0; caret_idx < tx->get_caret_count(); caret_idx++) {
- tx->toggle_foldable_line(tx->get_caret_line(caret_idx));
+ int previous_line = -1;
+ for (int caret_idx : tx->get_caret_index_edit_order()) {
+ int line_idx = tx->get_caret_line(caret_idx);
+ if (line_idx != previous_line) {
+ tx->toggle_foldable_line(line_idx);
+ previous_line = line_idx;
+ }
}
tx->queue_redraw();
} break;
diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp
index ceb170d7d8..9c0d76a6d3 100644
--- a/editor/plugins/text_editor.cpp
+++ b/editor/plugins/text_editor.cpp
@@ -397,8 +397,13 @@ void TextEditor::_edit_option(int p_op) {
code_editor->duplicate_selection();
} break;
case EDIT_TOGGLE_FOLD_LINE: {
- for (int caret_idx = 0; caret_idx < tx->get_caret_count(); caret_idx++) {
- tx->toggle_foldable_line(tx->get_caret_line(caret_idx));
+ int previous_line = -1;
+ for (int caret_idx : tx->get_caret_index_edit_order()) {
+ int line_idx = tx->get_caret_line(caret_idx);
+ if (line_idx != previous_line) {
+ tx->toggle_foldable_line(line_idx);
+ previous_line = line_idx;
+ }
}
tx->queue_redraw();
} break;