summaryrefslogtreecommitdiffstats
path: root/editor/code_editor.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-10-05 10:08:58 +0200
committerRémi Verschelde <rverschelde@gmail.com>2023-10-05 10:08:58 +0200
commitaa554e82785ff4c446532f121427c6ea6b4d15e6 (patch)
tree0a1e834a0b19647a6586f5e25db6c87ac5065757 /editor/code_editor.cpp
parent829d9bb6ba24ad955ac8fd29a88ed25572adc1dd (diff)
parent676627e1d16367616c7022df8d12c836c201c5f4 (diff)
downloadredot-engine-aa554e82785ff4c446532f121427c6ea6b4d15e6.tar.gz
Merge pull request #82694 from BrianMacIntosh/master
"Whole Words" search can detect word boundaries inside the search term.
Diffstat (limited to 'editor/code_editor.cpp')
-rw-r--r--editor/code_editor.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index 56e405bfcf..64467bc254 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -368,6 +368,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);
@@ -376,11 +379,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;
}