diff options
author | Juan Linietsky <reduzio@gmail.com> | 2018-04-07 16:33:31 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-07 16:33:31 -0300 |
commit | b6bf26a549b163ae35ff208223a6ce6b59489b0b (patch) | |
tree | bac2caa5b630ac7eb899ab70ea49bf02402bdf82 /editor | |
parent | 7dedb22f0b0689dce56e73572e69f64974ef2892 (diff) | |
parent | efd413916eac10e4bcfe4156bbe086264b180340 (diff) |
Merge pull request #17754 from Crazy-P/Resloves_Replace_all_doesnt_replace_all
Resloves Replace all doesnt replace all
Diffstat (limited to 'editor')
-rw-r--r-- | editor/code_editor.cpp | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 9ae9ab1501..4c7f2f53cc 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -212,35 +212,39 @@ void FindReplaceBar::_replace_all() { text_edit->begin_complex_operation(); - while (search_next()) { - - // replace area - Point2i match_from(result_line, result_col); - Point2i match_to(result_line, result_col + search_text_len); - - if (match_from < prev_match) - break; // done + if (search_current()) { + do { + // replace area + Point2i match_from(result_line, result_col); + Point2i match_to(result_line, result_col + search_text_len); + + if (match_from < prev_match) { + break; // done + } - prev_match = Point2i(result_line, result_col + replace_text.length()); + prev_match = Point2i(result_line, result_col + replace_text.length()); - text_edit->unfold_line(result_line); - text_edit->select(result_line, result_col, result_line, match_to.y); + text_edit->unfold_line(result_line); + text_edit->select(result_line, result_col, result_line, match_to.y); - if (selection_enabled && is_selection_only()) { + if (selection_enabled && is_selection_only()) { + if (match_from < selection_begin || match_to > selection_end) { + continue; + } - if (match_from < selection_begin || match_to > selection_end) - continue; + // replace but adjust selection bounds + text_edit->insert_text_at_cursor(replace_text); + if (match_to.x == selection_end.x) { + selection_end.y += replace_text.length() - search_text_len; + } - // replace but adjust selection bounds - text_edit->insert_text_at_cursor(replace_text); - if (match_to.x == selection_end.x) - selection_end.y += replace_text.length() - search_text_len; - } else { - // just replace - text_edit->insert_text_at_cursor(replace_text); - } + } else { + // just replace + text_edit->insert_text_at_cursor(replace_text); + } - rc++; + rc++; + } while (search_next()); } text_edit->end_complex_operation(); |