[LyX/master] #8055 correct processing of LFUN_WORD_FIND option flags for repeated search operations

Stephan Witt switt at lyx.org
Sat Feb 13 03:46:06 UTC 2021


commit 46bb8f22c9ae8a39476ce8f89a9c58d8f3bd6a43
Author: Stephan Witt <switt at lyx.org>
Date:   Fri Feb 12 22:20:02 2021 +0100

    #8055 correct processing of LFUN_WORD_FIND option flags for repeated search operations
---
 src/BufferView.cpp |    7 +++++--
 src/lyxfind.cpp    |   33 +++++++++++++++++++++++----------
 src/lyxfind.h      |    8 ++++++++
 3 files changed, 36 insertions(+), 12 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 84f107a..b67775e 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 7a5a46b..4c629b3 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
 	// "<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);
 }
diff --git a/src/lyxfind.h b/src/lyxfind.h
index 30c1ddd..88f06fe 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.
  */


More information about the lyx-cvs mailing list