summaryrefslogtreecommitdiffstats
path: root/tests/scene
diff options
context:
space:
mode:
authorRafael Chuva <rafael.chuva@tecnico.ulisboa.pt>2024-03-07 03:10:17 +0000
committerRafael Chuva <rafael.chuva@tecnico.ulisboa.pt>2024-03-11 00:04:39 +0000
commit8c36282febcde3a417d8ed3a8f5996c285829abd (patch)
tree18c857c15468de2fcd692d520383737a01244e93 /tests/scene
parent810f127022ec2cbfb288e436151d1a777c7b5da7 (diff)
downloadredot-engine-8c36282febcde3a417d8ed3a8f5996c285829abd.tar.gz
Fix region section not ignoring #region and #endregion when in a string
When using the script editor, if the keywords #region and #endregion where in a string and ate the start of the line, the editor would not ignore them and count them as the actual keywords, which when folded, would only fold until the first #endregion in a string, for example. By checking if these keywords were in a string, this commit now ensures the editor ignores strings and fold the section correctly. Fixes #89115.
Diffstat (limited to 'tests/scene')
-rw-r--r--tests/scene/test_code_edit.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/scene/test_code_edit.h b/tests/scene/test_code_edit.h
index 7d98372327..bc2f7f51b1 100644
--- a/tests/scene/test_code_edit.h
+++ b/tests/scene/test_code_edit.h
@@ -3048,6 +3048,28 @@ TEST_CASE("[SceneTree][CodeEdit] region folding") {
CHECK(code_edit->get_next_visible_line_offset_from(1, 1) == 4);
code_edit->unfold_line(1);
CHECK_FALSE(code_edit->is_line_folded(0));
+
+ // Region start and end tags are ignored if in a string and at the start of the line.
+ code_edit->clear_comment_delimiters();
+ code_edit->add_comment_delimiter("#", "");
+ code_edit->clear_string_delimiters();
+ code_edit->add_string_delimiter("\"", "\"");
+ code_edit->set_text("#region region_name1\nline2\n\"\n#region region_name2\n#endregion\n\"\n#endregion\nvisible");
+ CHECK(code_edit->is_line_code_region_start(0));
+ CHECK(code_edit->is_line_code_region_end(6));
+ CHECK(code_edit->can_fold_line(0));
+ for (int i = 1; i < 7; i++) {
+ if (i == 2) {
+ continue;
+ }
+ CHECK_FALSE(code_edit->can_fold_line(i));
+ }
+ for (int i = 0; i < 7; i++) {
+ CHECK_FALSE(code_edit->is_line_folded(i));
+ }
+ code_edit->fold_line(0);
+ CHECK(code_edit->is_line_folded(0));
+ CHECK(code_edit->get_next_visible_line_offset_from(1, 1) == 7);
}
memdelete(code_edit);