diff options
Diffstat (limited to 'scene/gui/code_edit.cpp')
-rw-r--r-- | scene/gui/code_edit.cpp | 33 |
1 files changed, 8 insertions, 25 deletions
diff --git a/scene/gui/code_edit.cpp b/scene/gui/code_edit.cpp index 7fba94da4c..a8c5966569 100644 --- a/scene/gui/code_edit.cpp +++ b/scene/gui/code_edit.cpp @@ -1419,40 +1419,23 @@ void CodeEdit::fold_line(int p_line) { /* End line is the same therefore we have a block of single line delimiters. */ if (end_line == p_line) { for (int i = p_line + 1; i <= line_count; i++) { - if (i == line_count) { - end_line = line_count; - break; - } - if ((in_string != -1 && is_in_string(i) == -1) || (in_comment != -1 && is_in_comment(i) == -1)) { - end_line = i - 1; break; } + end_line = i; } } } else { int start_indent = get_indent_level(p_line); for (int i = p_line + 1; i <= line_count; i++) { - if (get_line(p_line).strip_edges().size() == 0 || is_in_string(i) != -1 || is_in_comment(i) != -1) { - end_line = i; + if (get_line(i).strip_edges().size() == 0) { continue; } - - if (i == line_count) { - /* Do not fold empty last line of script if any */ + if (get_indent_level(i) > start_indent) { end_line = i; - if (get_line(i).strip_edges().size() == 0) { - end_line--; - } - break; + continue; } - - if ((get_indent_level(i) <= start_indent && get_line(i).strip_edges().size() != 0)) { - /* Keep an empty line unfolded if any */ - end_line = i - 1; - if (get_line(i - 1).strip_edges().size() == 0 && i - 2 > p_line) { - end_line = i - 2; - } + if (is_in_string(i) == -1 && is_in_comment(i) == -1) { break; } } @@ -2395,7 +2378,7 @@ void CodeEdit::_update_delimiter_cache(int p_from_line, int p_to_line) { if (start_line != end_line) { if (p_to_line < p_from_line) { for (int i = end_line; i > start_line; i--) { - delimiter_cache.remove(i); + delimiter_cache.remove_at(i); } } else { for (int i = start_line; i < end_line; i++) { @@ -2632,7 +2615,7 @@ void CodeEdit::_remove_delimiter(const String &p_start_key, DelimiterType p_type break; } - delimiters.remove(i); + delimiters.remove_at(i); if (!setting_delimiters) { delimiter_cache.clear(); _update_delimiter_cache(); @@ -2673,7 +2656,7 @@ void CodeEdit::_set_delimiters(const TypedArray<String> &p_delimiters, Delimiter void CodeEdit::_clear_delimiters(DelimiterType p_type) { for (int i = delimiters.size() - 1; i >= 0; i--) { if (delimiters[i].type == p_type) { - delimiters.remove(i); + delimiters.remove_at(i); } } delimiter_cache.clear(); |