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.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38883 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Tommaso Cucinotta 2011-05-29 13:40:34 +00:00
parent b9f6d8999c
commit 2d8108cf4c
2 changed files with 14 additions and 3 deletions

View File

@ -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

View File

@ -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 @@ docstring stringifyFromCursor(DocIterator const & cur, int len)
<< 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();