]> git.lyx.org Git - features.git/commitdiff
refactor: keep meaning of a variable consistent
authorScott Kostyshak <skostysh@lyx.org>
Wed, 2 Jun 2021 03:59:40 +0000 (23:59 -0400)
committerScott Kostyshak <skostysh@lyx.org>
Fri, 16 Jul 2021 19:50:30 +0000 (15:50 -0400)
We now use a new variable, "wrap", to track if a wrap should be
done, which is true either if "auto_wrap" is true or if the user
chooses to wrap in the dialog.

This preserves the meaning of the "auto_wrap" variable and also
removes the confusion of why the previous code of

  if (!auto_wrap) {
    ...
  }
  if (auto_wrap) {

did not use an "else" instead of the second "if".

No change in functionality.

src/lyxfind.cpp
src/lyxfind.h

index 6aa39aa2b8dc0ddc24b81e0e2619d79755c94b05..1760c94384ead028602d481fcf791e9e0041b5ff 100644 (file)
@@ -276,7 +276,7 @@ bool searchAllowed(docstring const & str)
 
 bool findOne(BufferView * bv, docstring const & searchstr,
             bool case_sens, bool whole, bool forward,
-            bool find_del, bool check_wrap, bool auto_wrap,
+            bool find_del, bool check_wrap, bool const auto_wrap,
             bool instant, bool onlysel)
 {
        // Clean up previous selections with empty searchstr on instant
@@ -338,6 +338,7 @@ bool findOne(BufferView * bv, docstring const & searchstr,
        }
        else if (check_wrap) {
                DocIterator cur_orig(bv->cursor());
+               bool wrap = auto_wrap;
                if (!auto_wrap) {
                        docstring q;
                        if (forward)
@@ -348,9 +349,9 @@ bool findOne(BufferView * bv, docstring const & searchstr,
                                  "Continue searching from the end?");
                        int wrap_answer = frontend::Alert::prompt(_("Wrap search?"),
                                q, 0, 1, _("&Yes"), _("&No"));
-                       auto_wrap = wrap_answer == 0;
+                       wrap = wrap_answer == 0;
                }
-               if (auto_wrap) {
+               if (wrap) {
                        if (forward) {
                                bv->cursor().clear();
                                bv->cursor().push_back(CursorSlice(bv->buffer().inset()));
index f79ef240cd1415ffea4161ebcbce9668b83e35b1..b700e0ce1a5065013f8bc1cdf1d2c4d43a72fab2 100644 (file)
@@ -74,7 +74,7 @@ bool lyxfind(BufferView * bv, FuncRequest const & ev);
 bool findOne(BufferView * bv, docstring const & searchstr,
             bool case_sens, bool whole, bool forward,
             bool find_del = true, bool check_wrap = false,
-            bool auto_wrap = false, bool instant = false,
+            bool const auto_wrap = false, bool instant = false,
             bool onlysel = false);
 
 /** Parse the string encoding of the replace request that is found in