Merge pull request #73704 from KoBeWi/script_origami

Fix line folding with multiple carets
This commit is contained in:
Rémi Verschelde 2023-02-21 23:35:41 +01:00
commit 9b774ef350
No known key found for this signature in database
GPG key ID: C3336907360768E1
2 changed files with 14 additions and 4 deletions

View file

@ -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;

View file

@ -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;