Change code folding behavior to include terminal indented comments

Previously, when folding a block of code that finished with an indented comment (i.e. one indented as much as or more than the starting indent of the code), that comment would be left out of the fold. Change the behavior to include such comments, but still leave less-indented ones out.

(cherry picked from commit efed5087ae)
This commit is contained in:
SnailRhymer 2022-07-17 17:38:51 +01:00 committed by Rémi Verschelde
parent 0bd6814cc6
commit 6426f2e9c7
1 changed files with 2 additions and 1 deletions

View File

@ -6341,7 +6341,8 @@ void TextEdit::fold_line(int p_line) {
int last_line = start_indent;
for (int i = p_line + 1; i < text.size(); i++) {
if (text[i].strip_edges().size() != 0) {
if (is_line_comment(i)) {
if (is_line_comment(i) && get_indent_level(i) <= start_indent) {
// Checked indent to make sure indented comments that finish a code block are folded.
continue;
} else if (get_indent_level(i) > start_indent) {
last_line = i;