summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgnacio Etcheverry <ignalfonsore@gmail.com>2016-07-30 01:11:02 +0200
committerIgnacio Etcheverry <ignalfonsore@gmail.com>2016-07-30 01:11:02 +0200
commit6e137c02d26df269c9860ac69e9d8824e4b5336b (patch)
treea1ca64f98b83e83808a9521fe51e731b1e531766
parent0dc2adad46590f2c9b34624e4a5b60dca768c9ae (diff)
Fix infinite loop when replacing text
-rw-r--r--tools/editor/code_editor.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/tools/editor/code_editor.cpp b/tools/editor/code_editor.cpp
index ed7a46d70d..d2bf070f1b 100644
--- a/tools/editor/code_editor.cpp
+++ b/tools/editor/code_editor.cpp
@@ -188,7 +188,9 @@ void FindReplaceBar::_replace_all() {
text_edit->cursor_set_line(0);
text_edit->cursor_set_column(0);
+ String replace_text=get_replace_text();
int search_text_len=get_search_text().length();
+
int rc=0;
replace_all_mode = true;
@@ -204,7 +206,7 @@ void FindReplaceBar::_replace_all() {
if (match_from < prev_match)
break; // done
- prev_match=match_to;
+ prev_match=Point2i(result_line,result_col+replace_text.length());
text_edit->select(result_line,result_col,result_line,match_to.y);
@@ -214,12 +216,12 @@ void FindReplaceBar::_replace_all() {
continue;
// replace but adjust selection bounds
- text_edit->insert_text_at_cursor(get_replace_text());
+ text_edit->insert_text_at_cursor(replace_text);
if (match_to.x==selection_end.x)
- selection_end.y+=get_replace_text().length() - get_search_text().length();
+ selection_end.y+=replace_text.length()-search_text_len;
} else {
// just replace
- text_edit->insert_text_at_cursor(get_replace_text());
+ text_edit->insert_text_at_cursor(replace_text);
}
rc++;