[LyX/2.4.1-devel] FindAdv: sometimes a space is added on some math symbols

Kornel Benko kornel at lyx.org
Sat Jun 1 11:36:10 UTC 2024


commit fca59304da642b57a6fba3ca4793a3c90e8bb7db
Author: Kornel Benko <kornel at lyx.org>
Date:   Wed May 29 14:09:20 2024 +0200

    FindAdv: sometimes a space is added on some math symbols
    
    For example '\int '.
    Should fix regression #13070
    Spotted  by Alexander Dunlap
    
    (cherry picked from commit 4730ec78f544b6fd51defd063e52955554b14e89)
    (cherry picked from commit 6c3447c8a62d1ed9c8e17732f991296123c69efb)
---
 src/lyxfind.cpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp
index 6e3b324bfa..2db9035848 100644
--- a/src/lyxfind.cpp
+++ b/src/lyxfind.cpp
@@ -1309,7 +1309,12 @@ static docstring stringifySearchBuffer(Buffer & buffer, FindAndReplaceOptions co
 		}
 		// Even in ignore-format we have to remove "\text{}, \lyxmathsym{}" parts
 		while (regex_replace(t, t, "\\\\(text|lyxmathsym|ensuremath)\\{([^\\}]*)\\}", "$2"));
-		str = from_utf8(t);
+		// remove trailing space, it may have  been added by plaintext() in InsetMathHull.cpp
+		size_t t_size = t.size();
+		if (opt.ignoreformat && (t_size > 1) && (t[t_size-1] == ' '))
+			str =  from_utf8(t.substr(0, t_size-1));
+		else
+			str = from_utf8(t);
 	}
 	return str;
 }


More information about the lyx-cvs mailing list