diff options
author | Brian MacIntosh <brianamacintosh@gmail.com> | 2023-10-02 13:30:23 -0700 |
---|---|---|
committer | Brian MacIntosh <brianamacintosh@gmail.com> | 2023-10-02 13:47:59 -0700 |
commit | 676627e1d16367616c7022df8d12c836c201c5f4 (patch) | |
tree | d8cb357858d3041fea07152ba88bfb4b8ce4de2a /tests | |
parent | a2f90d565ad29edcb3bdab77bc7df51cdde8514a (diff) | |
download | redot-engine-676627e1d16367616c7022df8d12c836c201c5f4.tar.gz |
"Whole Words" search can detect word boundaries inside the search term.
For example, searching for ".func" will now match in "a.func" even with Whole Words enabled.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/scene/test_text_edit.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/tests/scene/test_text_edit.h b/tests/scene/test_text_edit.h index 7e9b472af1..840a04becf 100644 --- a/tests/scene/test_text_edit.h +++ b/tests/scene/test_text_edit.h @@ -3193,7 +3193,7 @@ TEST_CASE("[SceneTree][TextEdit] search") { TextEdit *text_edit = memnew(TextEdit); SceneTree::get_singleton()->get_root()->add_child(text_edit); - text_edit->set_text("hay needle, hay\nHAY NEEDLE, HAY"); + text_edit->set_text("hay needle, hay\nHAY NEEDLE, HAY\nwordword.word.word"); int length = text_edit->get_line(1).length(); CHECK(text_edit->search("test", 0, 0, 0) == Point2i(-1, -1)); @@ -3225,6 +3225,11 @@ TEST_CASE("[SceneTree][TextEdit] search") { CHECK(text_edit->search("need", TextEdit::SEARCH_WHOLE_WORDS | TextEdit::SEARCH_MATCH_CASE, 0, 0) == Point2i(-1, -1)); CHECK(text_edit->search("need", TextEdit::SEARCH_WHOLE_WORDS | TextEdit::SEARCH_MATCH_CASE | TextEdit::SEARCH_BACKWARDS, 0, 0) == Point2i(-1, -1)); + CHECK(text_edit->search("word", TextEdit::SEARCH_WHOLE_WORDS, 2, 0) == Point2i(9, 2)); + CHECK(text_edit->search("word", TextEdit::SEARCH_WHOLE_WORDS, 2, 10) == Point2i(14, 2)); + CHECK(text_edit->search(".word", TextEdit::SEARCH_WHOLE_WORDS, 2, 0) == Point2i(8, 2)); + CHECK(text_edit->search("word.", TextEdit::SEARCH_WHOLE_WORDS, 2, 0) == Point2i(9, 2)); + ERR_PRINT_OFF; CHECK(text_edit->search("", 0, 0, 0) == Point2i(-1, -1)); CHECK(text_edit->search("needle", 0, -1, 0) == Point2i(-1, -1)); |