diff options
-rw-r--r-- | editor/plugins/script_text_editor.cpp | 9 | ||||
-rw-r--r-- | editor/plugins/text_editor.cpp | 9 |
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; |