From efed5087ae75a13e58cc06da5323f6f6448819a4 Mon Sep 17 00:00:00 2001 From: SnailRhymer Date: Sun, 17 Jul 2022 17:38:51 +0100 Subject: [PATCH] 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. --- scene/gui/text_edit.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 5d092e6c0df..3477e69b61c 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -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;