From: Stephan Witt Date: Fri, 12 Feb 2021 21:20:02 +0000 (+0100) Subject: #8055 correct processing of LFUN_WORD_FIND option flags for repeated search operations X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=46bb8f22c9ae8a39476ce8f89a9c58d8f3bd6a43;p=features.git #8055 correct processing of LFUN_WORD_FIND option flags for repeated search operations --- diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 84f107a5b9..b67775ecd8 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -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); diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp index 7a5a46ba83..4c629b309c 100644 --- a/src/lyxfind.cpp +++ b/src/lyxfind.cpp @@ -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 // " // " 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); } diff --git a/src/lyxfind.h b/src/lyxfind.h index 30c1ddde0d..88f06fe7f1 100644 --- a/src/lyxfind.h +++ b/src/lyxfind.h @@ -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. */