Fix match count for whole word search in editor
Check if a match borders a new line char when incrementing match counts.
This commit is contained in:
parent
6fa2a5ac14
commit
91bdc77d47
|
@ -307,18 +307,19 @@ void FindReplaceBar::_update_results_count() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int pos_subsequent = pos + searched.length();
|
||||||
if (is_whole_words()) {
|
if (is_whole_words()) {
|
||||||
from_pos = pos + 1; // Making sure we won't hit the same match next time, if we get out via a continue.
|
from_pos = pos + 1; // Making sure we won't hit the same match next time, if we get out via a continue.
|
||||||
if (pos > 0 && !is_symbol(full_text[pos - 1])) {
|
if (pos > 0 && !(is_symbol(full_text[pos - 1]) || full_text[pos - 1] == '\n')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (pos + searched.length() < full_text.length() && !is_symbol(full_text[pos + searched.length()])) {
|
if (pos_subsequent < full_text.length() && !(is_symbol(full_text[pos_subsequent]) || full_text[pos_subsequent] == '\n')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
results_count++;
|
results_count++;
|
||||||
from_pos = pos + searched.length();
|
from_pos = pos_subsequent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue