Merge pull request #5966 from neikeq/pr-issue-5935

Fix infinite loop when replacing text
This commit is contained in:
Rémi Verschelde 2016-07-30 09:11:59 +02:00 committed by GitHub
commit 38286670ac

View file

@ -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++;