mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
Findadv: 'Optimized' detection of matched string
This is clearly a hack, because I don't understand why the previous code did not work.
This commit is contained in:
parent
1bed76e2a1
commit
aa68dcefa0
@ -798,7 +798,7 @@ static docstring buffer_to_latex(Buffer & buffer)
|
||||
otexstream os(ods);
|
||||
runparams.nice = true;
|
||||
runparams.flavor = OutputParams::LATEX;
|
||||
runparams.linelen = 80; //lyxrc.plaintext_linelen;
|
||||
runparams.linelen = 100000; //lyxrc.plaintext_linelen;
|
||||
// No side effect of file copying and image conversion
|
||||
runparams.dryrun = true;
|
||||
runparams.for_search = true;
|
||||
@ -1718,7 +1718,7 @@ void LatexInfo::removeHead(KeyInfo &actual, int count)
|
||||
|
||||
int LatexInfo::dispatch(ostringstream &os, int previousStart, KeyInfo &actual)
|
||||
{
|
||||
int nextKeyIdx;
|
||||
int nextKeyIdx = 0;
|
||||
switch (actual.keytype)
|
||||
{
|
||||
case KeyInfo::isChar: {
|
||||
@ -2458,10 +2458,33 @@ int findAdvFinalize(DocIterator & cur, MatchStringAdv const & match)
|
||||
if (old_len < 0) old_len = 0;
|
||||
int new_len;
|
||||
// Greedy behaviour while matching regexps
|
||||
while ((new_len = match(cur, len + 1)) > old_len) {
|
||||
++len;
|
||||
bool examining = true;
|
||||
int lastvalidlen = len;
|
||||
while (examining) {
|
||||
examining = false;
|
||||
// Kornel: The loop is needed, since it looks like
|
||||
// incrementing 'cur.pos()' does not always lead to the following
|
||||
// char which we could then match.
|
||||
for (int count = 1; count < 5; ++count) {
|
||||
if (cur.pos() + len + count > cur.lastpos()) {
|
||||
break;
|
||||
}
|
||||
new_len = match(cur, len + count);
|
||||
if (new_len > old_len) {
|
||||
len += count;
|
||||
old_len = new_len;
|
||||
LYXERR(Debug::FIND, "verifying match with len = " << len);
|
||||
examining = true;
|
||||
break;
|
||||
}
|
||||
else if (new_len == old_len)
|
||||
lastvalidlen = len+count;
|
||||
}
|
||||
}
|
||||
if (lastvalidlen == len + 1) {
|
||||
// Kornel: Don't know, why this is important
|
||||
// All I can see, is that sometimes the last char
|
||||
// is outside of a match although it should be inside
|
||||
len++;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user