[LyX/master] Support protected and thin space in simple search (#12836)

Juergen Spitzmueller spitz at lyx.org
Mon Jul 17 13:46:34 UTC 2023


commit f6f936e3d049c05ad0795c32696df895d8b61313
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Mon Jul 17 16:58:04 2023 +0200

    Support protected and thin space in simple search (#12836)
---
 src/Paragraph.cpp         |    2 +-
 src/insets/InsetSpace.cpp |   14 +++++++++++---
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index 025acf1..d7fa35e 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -4669,7 +4669,7 @@ int Paragraph::find(docstring const & str, bool cs, bool mw,
 			if (!inset->isLetter() && !inset->isChar())
 				break;
 			odocstringstream os;
-			if (inset->lyxCode() == lyx::QUOTE_CODE) {
+			if (inset->lyxCode() == lyx::QUOTE_CODE || inset->lyxCode() == lyx::SPACE_CODE) {
 				OutputParams op(0);
 				op.find_set_feature(OutputParams::SearchQuick);
 				inset->plaintext(os, op);
diff --git a/src/insets/InsetSpace.cpp b/src/insets/InsetSpace.cpp
index a5b0464..14db93f 100644
--- a/src/insets/InsetSpace.cpp
+++ b/src/insets/InsetSpace.cpp
@@ -703,7 +703,7 @@ void InsetSpace::latex(otexstream & os, OutputParams const & runparams) const
 
 
 int InsetSpace::plaintext(odocstringstream & os,
-        OutputParams const &, size_t) const
+        OutputParams const & rp, size_t) const
 {
 	switch (params_.kind) {
 	case InsetSpaceParams::HFILL:
@@ -747,7 +747,11 @@ int InsetSpace::plaintext(odocstringstream & os,
 		os.put(0x2003);
 		return 2;
 	case InsetSpaceParams::THIN:
-		os.put(0x202f);
+		if (rp.find_effective())
+			// simple search
+			os << ' ';
+		else
+			os.put(0x202f);
 		return 1;
 	case InsetSpaceParams::MEDIUM:
 		os.put(0x200b); // ZERO WIDTH SPACE, makes the unbreakable medium space breakable
@@ -761,7 +765,11 @@ int InsetSpace::plaintext(odocstringstream & os,
 		return 1;
 	case InsetSpaceParams::PROTECTED:
 	case InsetSpaceParams::CUSTOM_PROTECTED:
-		os.put(0x00a0);
+		if (rp.find_effective())
+			// simple search
+			os << ' ';
+		else
+			os.put(0x00a0);
 		return 1;
 	case InsetSpaceParams::NEGTHIN:
 	case InsetSpaceParams::NEGMEDIUM:


More information about the lyx-cvs mailing list