diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 4a82f6e7259..cffd9604f6e 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -7000,6 +7000,11 @@ int TextEdit::_get_column_pos_of_word(const String &p_key, const String &p_searc col = p_search.findn(p_key, p_from_column); } + // If not found, just break early to improve performance. + if (col == -1) { + break; + } + // Whole words only. if (col != -1 && p_search_flags & SEARCH_WHOLE_WORDS) { p_from_column = col;