#8055 correct processing of LFUN_WORD_FIND option flags for repeated search operations

This commit is contained in:
Stephan Witt 2021-02-12 22:20:02 +01:00
parent 400cb1b80f
commit 46bb8f22c9
3 changed files with 36 additions and 12 deletions

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

View File

@ -459,22 +459,35 @@ docstring const replace2string(docstring const & replace,
}
docstring const string2find(docstring const & argument,
bool &casesensitive,
bool &matchword,
bool &forward)
{
// data is of the form
// "<search>
// <casesensitive> <matchword> <forward>"
docstring search;
docstring howto = split(argument, search, '\n');
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;
// data is of the form
// "<search>
// <casesensitive> <matchword> <forward>"
docstring search;
docstring howto = split(ev.argument(), search, '\n');
bool casesensitive = parse_bool(howto);
bool matchword = parse_bool(howto);
bool forward = parse_bool(howto);
bool casesensitive;
bool matchword;
bool forward;
docstring search = string2find(ev.argument(), casesensitive, matchword, forward);
return findOne(bv, search, casesensitive, matchword, forward, false, true);
}

View 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.
*/