refactor: keep meaning of a variable consistent

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.
This commit is contained in:
Scott Kostyshak 2021-06-01 23:59:40 -04:00
parent c93c94fd22
commit abc65d4700
2 changed files with 5 additions and 4 deletions

View 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()));

View 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