diff options
author | Nathan Franke <me@nathan.sh> | 2022-04-25 14:56:47 -0500 |
---|---|---|
committer | Nathan Franke <me@nathan.sh> | 2022-04-28 20:07:10 -0500 |
commit | 925e54ad65d30eb1eecdde31502dd554bf00bce7 (patch) | |
tree | 251af3320f6189cb7f45ef650642e54d89e6c0d7 /tests/scene | |
parent | cbdc33bcf73090962e60c1cf5ee50a21b29e4bad (diff) |
fix lines ending in comments causing auto indent
Diffstat (limited to 'tests/scene')
-rw-r--r-- | tests/scene/test_code_edit.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/scene/test_code_edit.h b/tests/scene/test_code_edit.h index 574cacda95..62931cd4dd 100644 --- a/tests/scene/test_code_edit.h +++ b/tests/scene/test_code_edit.h @@ -2179,8 +2179,24 @@ TEST_CASE("[SceneTree][CodeEdit] indent") { SEND_GUI_ACTION(code_edit, "ui_text_newline"); CHECK(code_edit->get_line(0) == "test: # string"); CHECK(code_edit->get_line(1) == ""); + code_edit->remove_string_delimiter("#"); + + /* Non-whitespace prevents auto-indentation. */ + code_edit->add_comment_delimiter("#", ""); + code_edit->set_text(""); + code_edit->insert_text_at_caret("test := 0 # comment"); + SEND_GUI_ACTION(code_edit, "ui_text_newline"); + CHECK(code_edit->get_line(0) == "test := 0 # comment"); + CHECK(code_edit->get_line(1) == ""); code_edit->remove_comment_delimiter("#"); + /* Even when there's no comments. */ + code_edit->set_text(""); + code_edit->insert_text_at_caret("test := 0"); + SEND_GUI_ACTION(code_edit, "ui_text_newline"); + CHECK(code_edit->get_line(0) == "test := 0"); + CHECK(code_edit->get_line(1) == ""); + /* If between brace pairs an extra line is added. */ code_edit->set_text(""); code_edit->insert_text_at_caret("test{}"); @@ -2256,8 +2272,24 @@ TEST_CASE("[SceneTree][CodeEdit] indent") { SEND_GUI_ACTION(code_edit, "ui_text_newline"); CHECK(code_edit->get_line(0) == "test: # string"); CHECK(code_edit->get_line(1) == ""); + code_edit->remove_string_delimiter("#"); + + /* Non-whitespace prevents auto-indentation. */ + code_edit->add_comment_delimiter("#", ""); + code_edit->set_text(""); + code_edit->insert_text_at_caret("test := 0 # comment"); + SEND_GUI_ACTION(code_edit, "ui_text_newline"); + CHECK(code_edit->get_line(0) == "test := 0 # comment"); + CHECK(code_edit->get_line(1) == ""); code_edit->remove_comment_delimiter("#"); + /* Even when there's no comments. */ + code_edit->set_text(""); + code_edit->insert_text_at_caret("test := 0"); + SEND_GUI_ACTION(code_edit, "ui_text_newline"); + CHECK(code_edit->get_line(0) == "test := 0"); + CHECK(code_edit->get_line(1) == ""); + /* If between brace pairs an extra line is added. */ code_edit->set_text(""); code_edit->insert_text_at_caret("test{}"); |