Author: tommaso
Date: Sun May 29 15:40:34 2011
New Revision: 38883
URL: http://www.lyx.org/trac/changeset/38883

Log:
Avoid extra ' ' in text-only export of consecutive macros in math mode, for 
Advanced F&R matching.
For example, this wasn't allowing to match '\beta\alpha' in the sequence 
'\alpha\beta\alpha', as
in the accompanying regression test-case.

Added:
   lyx-devel/trunk/development/autotests/findadv-17-in.txt
Modified:
   lyx-devel/trunk/src/lyxfind.cpp

Added: lyx-devel/trunk/development/autotests/findadv-17-in.txt
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ lyx-devel/trunk/development/autotests/findadv-17-in.txt     Sun May 29 
15:40:34 2011        (r38883)
@@ -0,0 +1,9 @@
+# Finding consecutive macros in math mode
+#
+Lang it_IT.utf8
+TestBegin test.lyx -dbg find > lyx-log.txt 2>&1
+KK: \Cm\\alpha\\beta\\alpha \C\[Home]
+KK: \CF
+KK: \Cm\\beta\\alpha \[Return]
+TestEnd
+Assert pcregrep -M 'Putting selection at .*idx: 0 par: 0 pos: 0\n.*idx: 0 par: 
0 pos: 1\n with len: 2' lyx-log.txt

Modified: lyx-devel/trunk/src/lyxfind.cpp
==============================================================================
--- lyx-devel/trunk/src/lyxfind.cpp     Sun May 29 15:19:41 2011        (r38882)
+++ lyx-devel/trunk/src/lyxfind.cpp     Sun May 29 15:40:34 2011        (r38883)
@@ -40,6 +40,7 @@
 #include "mathed/InsetMathGrid.h"
 #include "mathed/InsetMathHull.h"
 #include "mathed/MathStream.h"
+#include "mathed/MathSupport.h"
 
 #include "support/convert.h"
 #include "support/debug.h"
@@ -966,15 +967,16 @@
                                << cur << ", from pos: " << cur.pos() << ", 
end: " << end);
                        return par.stringify(cur.pos(), end, AS_STR_INSETS, 
runparams);
        } else if (cur.inMathed()) {
-                       odocstringstream os;
+                       docstring s;
                        CursorSlice cs = cur.top();
                        MathData md = cs.cell();
                        MathData::const_iterator it_end = 
                                ( ( len == -1 || cs.pos() + len > 
int(md.size()) )
                                        ? md.end() : md.begin() + cs.pos() + 
len );
                        for (MathData::const_iterator it = md.begin() + 
cs.pos(); it != it_end; ++it)
-                                       os << *it;
-                       return os.str();
+                               s = s + asString(*it);
+                       LYXERR(Debug::FIND, "Stringified math: '" << s << "'");
+                       return s;
        }
        LYXERR(Debug::FIND, "Don't know how to stringify from here: " << cur);
        return docstring();

Reply via email to