diff options
author | huttongrabiel <huttonthomas@icloud.com> | 2022-08-14 18:26:23 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-08-15 13:09:56 +0200 |
commit | 27abbfdf093545d8c208f07aa1b9bafb14eaea93 (patch) | |
tree | 7c1c06f7909c7022bdf828a276f3427640b6b000 /Userland | |
parent | d43640037e29e3a7cbb34a363c526dd74ff86a93 (diff) | |
download | serenity-27abbfdf093545d8c208f07aa1b9bafb14eaea93.zip |
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.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Applications/TextEditor/MainWidget.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/Userland/Applications/TextEditor/MainWidget.cpp b/Userland/Applications/TextEditor/MainWidget.cpp index 94b128d74f..878084aad6 100644 --- a/Userland/Applications/TextEditor/MainWidget.cpp +++ b/Userland/Applications/TextEditor/MainWidget.cpp @@ -139,11 +139,18 @@ MainWidget::MainWidget() 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); - while (found_range.is_valid()) { - m_editor->set_selection(found_range); - m_editor->insert_at_cursor_or_replace_selection(substitute); - 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); + if (found_range.is_valid()) { + while (found_range.is_valid()) { + m_editor->set_selection(found_range); + m_editor->insert_at_cursor_or_replace_selection(substitute); + 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); } }); |