diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2022-10-10 10:03:16 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2022-10-10 10:03:16 +0200 |
commit | 1c3a63a970108ebd0168d7386036a92583df762c (patch) | |
tree | d9a4454252baf12d17d22708c594848458d6f49d | |
parent | d56bc199057273ea57c9a39f1fdbc623a14ce5d5 (diff) | |
parent | eac9adf7a10b4162f2e9d438a2da4f6c5d7d458c (diff) |
Merge pull request #67079 from timothyqiu/main-caret
Don't allow removing `TextEdit`'s main caret
-rw-r--r-- | scene/gui/text_edit.cpp | 2 | ||||
-rw-r--r-- | tests/scene/test_text_edit.h | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 2e7f650fc2..903e252a76 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -4380,7 +4380,7 @@ int TextEdit::add_caret(int p_line, int p_col) { } void TextEdit::remove_caret(int p_caret) { - ERR_FAIL_COND(carets.size() <= 0); + ERR_FAIL_COND_MSG(carets.size() <= 1, "The main caret should not be removed."); ERR_FAIL_INDEX(p_caret, carets.size()); carets.remove_at(p_caret); caret_index_edit_dirty = true; diff --git a/tests/scene/test_text_edit.h b/tests/scene/test_text_edit.h index 6b831bc9c7..3dfbd3e7b6 100644 --- a/tests/scene/test_text_edit.h +++ b/tests/scene/test_text_edit.h @@ -3321,6 +3321,11 @@ TEST_CASE("[SceneTree][TextEdit] muiticaret") { CHECK(text_edit->get_caret_count() == 1); CHECK(text_edit->get_caret_line(0) == 0); CHECK(text_edit->get_caret_column(0) == 1); + + ERR_PRINT_OFF; + text_edit->remove_caret(0); + CHECK(text_edit->get_caret_count() == 1); + ERR_PRINT_ON; } SUBCASE("[TextEdit] caret index edit order") { |