]> git.lyx.org Git - features.git/commitdiff
#8055 correct processing of LFUN_WORD_FIND option flags for repeated search operations
authorStephan Witt <switt@lyx.org>
Fri, 12 Feb 2021 21:20:02 +0000 (22:20 +0100)
committerStephan Witt <switt@lyx.org>
Sat, 13 Feb 2021 03:47:44 +0000 (04:47 +0100)
src/BufferView.cpp
src/lyxfind.cpp
src/lyxfind.h

index 84f107a5b9bddf44a778a42365fe76db2591e52d..b67775ecd84b3e9b5fa25346534ae61c51b44d9e 100644 (file)
@@ -1629,9 +1629,12 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                if (searched_string.empty())
                        break;
 
-               bool const fw = act == LFUN_WORD_FIND_FORWARD;
+               bool casesensitive;
+               bool matchword;
+               bool forward;
+               docstring const search = string2find(searched_string, casesensitive, matchword, forward);
                docstring const data =
-                       find2string(searched_string, true, false, fw);
+                       find2string(search, casesensitive, matchword, act == LFUN_WORD_FIND_FORWARD);
                bool found = lyxfind(this, FuncRequest(LFUN_WORD_FIND, data));
                if (found)
                        dr.screenUpdate(Update::Force | Update::FitCursor);
index 7a5a46ba83b702938edeaf5f4769f43f2a2c8297..4c629b309cc779d0c6e9aaf52bc2204a01c0b0f4 100644 (file)
@@ -459,22 +459,35 @@ docstring const replace2string(docstring const & replace,
 }
 
 
-bool lyxfind(BufferView * bv, FuncRequest const & ev)
+docstring const string2find(docstring const & argument,
+                             bool &casesensitive,
+                             bool &matchword,
+                             bool &forward)
 {
-       if (!bv || ev.action() != LFUN_WORD_FIND)
-               return false;
-
-       //lyxerr << "find called, cmd: " << ev << endl;
-
        // data is of the form
        // "<search>
        //  <casesensitive> <matchword> <forward>"
        docstring search;
-       docstring howto = split(ev.argument(), search, '\n');
+       docstring howto = split(argument, search, '\n');
 
-       bool casesensitive = parse_bool(howto);
-       bool matchword     = parse_bool(howto);
-       bool forward       = parse_bool(howto);
+       casesensitive = parse_bool(howto);
+       matchword     = parse_bool(howto);
+       forward       = parse_bool(howto);
+
+       return search;
+}
+
+
+bool lyxfind(BufferView * bv, FuncRequest const & ev)
+{
+       if (!bv || ev.action() != LFUN_WORD_FIND)
+               return false;
+
+       //lyxerr << "find called, cmd: " << ev << endl;
+       bool casesensitive;
+       bool matchword;
+       bool forward;
+       docstring search = string2find(ev.argument(), casesensitive, matchword, forward);
 
        return findOne(bv, search, casesensitive, matchword, forward, false, true);
 }
index 30c1ddde0d13af75dce3f56684f811ad6d5a0778..88f06fe7f1c5081c6ed1bd3e55ec5282a47bfffd 100644 (file)
@@ -28,6 +28,14 @@ class BufferView;
 class DocIterator;
 class FuncRequest;
 
+/** Decode the \c argument to extract search plus options from a string
+ *  that came to the LyX core in a FuncRequest wrapper.
+ */
+docstring const string2find(docstring const & argument,
+                             bool &casesensitive,
+                             bool &matchword,
+                             bool &forward);
+
 /** Encode the parameters needed to find \c search as a string
  *  that can be dispatched to the LyX core in a FuncRequest wrapper.
  */