diff options
author | ator-dev <dominic.codedeveloper@gmail.com> | 2021-11-24 22:36:04 +0000 |
---|---|---|
committer | ator-dev <dom@me> | 2021-11-24 22:43:06 +0000 |
commit | bac0a035c9deb48fc975eafb1533825592b2e947 (patch) | |
tree | e5d2fa219fbf1a256ebf418a9af9551022dce06f /scene | |
parent | 70d530029a8bdb1ca9840f2aaa32de04f5d69521 (diff) |
Fix code folding when end of block is unindented delimiter
Diffstat (limited to 'scene')
-rw-r--r-- | scene/gui/code_edit.cpp | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/scene/gui/code_edit.cpp b/scene/gui/code_edit.cpp index 7fba94da4c..e187b19c3c 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; } } |