]> git.lyx.org Git - lyx.git/commitdiff
FindAdv: sometimes a space is added on some math symbols
authorKornel Benko <kornel@lyx.org>
Wed, 29 May 2024 12:09:20 +0000 (14:09 +0200)
committerKornel Benko <kornel@lyx.org>
Wed, 29 May 2024 12:09:20 +0000 (14:09 +0200)
For example '\int '.
Should fix regression #13070
Spotted  by Alexander Dunlap

src/lyxfind.cpp

index 6e3b324bfa66be867f2bee4d4292bfd6b2ee3422..2db903584862f7117eca82339bcf1d1f3356db79 100644 (file)
@@ -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;
 }