diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2020-06-15 07:13:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-15 07:13:20 +0200 |
commit | fe858b74b8fbd345f1d08807abcf2b6dbea035a9 (patch) | |
tree | f98711ce392864a27a3a72f71a560d396f12ac42 | |
parent | 6fa2a5ac145054a29268735316f14d2afe46b381 (diff) | |
parent | 91bdc77d47eba2a0c74c07eb57ce5ee14538b535 (diff) |
Merge pull request #39552 from mrushyendra/whole_word_match_count
Fix match count for whole word search in editor
-rw-r--r-- | editor/code_editor.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 1b2b0a26e6..95c7cc0bf1 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -307,18 +307,19 @@ void FindReplaceBar::_update_results_count() { break; } + int pos_subsequent = pos + searched.length(); 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. - if (pos > 0 && !is_symbol(full_text[pos - 1])) { + if (pos > 0 && !(is_symbol(full_text[pos - 1]) || full_text[pos - 1] == '\n')) { 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; } } results_count++; - from_pos = pos + searched.length(); + from_pos = pos_subsequent; } } |