You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-02 16:48:55 +00:00
"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.
(cherry picked from commit 676627e1d1)
This commit is contained in:
committed by
Yuri Sizov
parent
222cba2aab
commit
04bd9cc06c
@@ -367,6 +367,9 @@ void FindReplaceBar::_update_results_count() {
|
||||
|
||||
int col_pos = 0;
|
||||
|
||||
bool searched_start_is_symbol = is_symbol(searched[0]);
|
||||
bool searched_end_is_symbol = is_symbol(searched[searched.length() - 1]);
|
||||
|
||||
while (true) {
|
||||
col_pos = is_case_sensitive() ? line_text.find(searched, col_pos) : line_text.findn(searched, col_pos);
|
||||
|
||||
@@ -375,11 +378,11 @@ void FindReplaceBar::_update_results_count() {
|
||||
}
|
||||
|
||||
if (is_whole_words()) {
|
||||
if (col_pos > 0 && !is_symbol(line_text[col_pos - 1])) {
|
||||
if (!searched_start_is_symbol && col_pos > 0 && !is_symbol(line_text[col_pos - 1])) {
|
||||
col_pos += searched.length();
|
||||
continue;
|
||||
}
|
||||
if (col_pos + searched.length() < line_text.length() && !is_symbol(line_text[col_pos + searched.length()])) {
|
||||
if (!searched_end_is_symbol && col_pos + searched.length() < line_text.length() && !is_symbol(line_text[col_pos + searched.length()])) {
|
||||
col_pos += searched.length();
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user