From fcecbf003c359ca7800f45d32fdeca71ed776a9b Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Wed, 25 Dec 2024 10:43:25 +0300 Subject: [PATCH] mcedit (editsearch): minor refactoring. * (edit_do_search): refactor check of search options. * (edit_replace_cmd): likewise. Signed-off-by: Andrew Borodin --- src/editor/editsearch.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/editor/editsearch.c b/src/editor/editsearch.c index b971c1be4..ca66540dc 100644 --- a/src/editor/editsearch.c +++ b/src/editor/editsearch.c @@ -615,13 +615,16 @@ edit_do_search (WEdit *edit) } else { - if (edit->found_len != 0 && edit->search_start == edit->found_start + 1 - && edit_search_options.backwards) - edit->search_start--; - - if (edit->found_len != 0 && edit->search_start == edit->found_start - 1 - && !edit_search_options.backwards) - edit->search_start++; + if (edit_search_options.backwards) + { + if (edit->found_len != 0 && edit->search_start == edit->found_start + 1) + edit->search_start--; + } + else + { + if (edit->found_len != 0 && edit->search_start == edit->found_start - 1) + edit->search_start++; + } if (edit_find (&esm, &len)) { @@ -868,13 +871,16 @@ edit_replace_cmd (WEdit *edit, gboolean again) goto cleanup; } - if (edit->found_len != 0 && edit->search_start == edit->found_start + 1 - && edit_search_options.backwards) - edit->search_start--; - - if (edit->found_len != 0 && edit->search_start == edit->found_start - 1 - && !edit_search_options.backwards) - edit->search_start++; + if (edit_search_options.backwards) + { + if (edit->found_len != 0 && edit->search_start == edit->found_start + 1) + edit->search_start--; + } + else + { + if (edit->found_len != 0 && edit->search_start == edit->found_start - 1) + edit->search_start++; + } esm.first = TRUE; esm.edit = edit;