diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2016-07-30 09:11:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-30 09:11:59 +0200 |
commit | 38286670acc1292eea8effb332aa47136f1f0be8 (patch) | |
tree | 701c0fd4b323fa2f851a4faa0537305628114872 /tools/editor/code_editor.cpp | |
parent | e300df517de211afc4d31ca51e74ab6202b86b12 (diff) | |
parent | 6e137c02d26df269c9860ac69e9d8824e4b5336b (diff) |
Merge pull request #5966 from neikeq/pr-issue-5935
Fix infinite loop when replacing text
Diffstat (limited to 'tools/editor/code_editor.cpp')
-rw-r--r-- | tools/editor/code_editor.cpp | 10 |
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++; |