mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:17:34 +00:00
TextEditor: Display widget when needle not found in replace all
When the given needle is not found, replace displays a widget that says the needle is not found, but replace all does not. This change adds that widget to replace all.
This commit is contained in:
parent
d43640037e
commit
27abbfdf09
1 changed files with 12 additions and 5 deletions
|
@ -139,11 +139,18 @@ MainWidget::MainWidget()
|
||||||
m_editor->document().update_regex_matches(needle);
|
m_editor->document().update_regex_matches(needle);
|
||||||
|
|
||||||
auto found_range = m_editor->document().find_next(needle, {}, GUI::TextDocument::SearchShouldWrap::No, m_use_regex, m_match_case);
|
auto found_range = m_editor->document().find_next(needle, {}, GUI::TextDocument::SearchShouldWrap::No, m_use_regex, m_match_case);
|
||||||
while (found_range.is_valid()) {
|
if (found_range.is_valid()) {
|
||||||
m_editor->set_selection(found_range);
|
while (found_range.is_valid()) {
|
||||||
m_editor->insert_at_cursor_or_replace_selection(substitute);
|
m_editor->set_selection(found_range);
|
||||||
auto next_start = GUI::TextPosition(found_range.end().line(), found_range.end().column() + length_delta);
|
m_editor->insert_at_cursor_or_replace_selection(substitute);
|
||||||
found_range = m_editor->document().find_next(needle, next_start, GUI::TextDocument::SearchShouldWrap::No, m_use_regex, m_match_case);
|
auto next_start = GUI::TextPosition(found_range.end().line(), found_range.end().column() + length_delta);
|
||||||
|
found_range = m_editor->document().find_next(needle, next_start, GUI::TextDocument::SearchShouldWrap::No, m_use_regex, m_match_case);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
GUI::MessageBox::show(window(),
|
||||||
|
String::formatted("Not found: \"{}\"", needle),
|
||||||
|
"Not found"sv,
|
||||||
|
GUI::MessageBox::Type::Information);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue