mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 21:21:32 +00:00
FindAdv: Do not use data from included listing if in search mode
Fixes #11496 "Find and replace (advanced)" is too slow
This commit is contained in:
parent
b1f93e0982
commit
aaffcd0b39
@ -967,10 +967,15 @@ int InsetInclude::plaintext(odocstringstream & os,
|
||||
}
|
||||
|
||||
if (isVerbatim(params()) || isListings(params())) {
|
||||
os << '[' << screenLabel() << '\n'
|
||||
// FIXME: We don't know the encoding of the file, default to UTF-8.
|
||||
<< includedFileName(buffer(), params()).fileContents("UTF-8")
|
||||
<< "\n]";
|
||||
if (op.for_search) {
|
||||
os << '[' << screenLabel() << ']';
|
||||
}
|
||||
else {
|
||||
os << '[' << screenLabel() << '\n'
|
||||
// FIXME: We don't know the encoding of the file, default to UTF-8.
|
||||
<< includedFileName(buffer(), params()).fileContents("UTF-8")
|
||||
<< "\n]";
|
||||
}
|
||||
return PLAINTEXT_NEWLINE + 1; // one char on a separate line
|
||||
}
|
||||
|
||||
|
@ -2920,12 +2920,12 @@ docstring stringifyFromCursor(DocIterator const & cur, int len)
|
||||
runparams.linelen = 10000; //lyxrc.plaintext_linelen;
|
||||
// No side effect of file copying and image conversion
|
||||
runparams.dryrun = true;
|
||||
runparams.for_search = true;
|
||||
LYXERR(Debug::FIND, "Stringifying with cur: "
|
||||
<< cur << ", from pos: " << cur.pos() << ", end: " << end);
|
||||
docstring result = par.asString(cur.pos(), end,
|
||||
return par.asString(cur.pos(), end,
|
||||
AS_STR_INSETS | AS_STR_SKIPDELETE | AS_STR_PLAINTEXT,
|
||||
&runparams);
|
||||
return result;
|
||||
} else if (cur.inMathed()) {
|
||||
CursorSlice cs = cur.top();
|
||||
MathData md = cs.cell();
|
||||
@ -3134,7 +3134,7 @@ int findForwardAdv(DocIterator & cur, MatchStringAdv & match)
|
||||
MatchResult mres = match(cur, -1, false);
|
||||
int match_len = mres.match_len;
|
||||
LYXERR(Debug::FIND, "match_len: " << match_len);
|
||||
if ((mres.pos > 10000) || (mres.match2end > 10000) || (match_len > 10000)) {
|
||||
if ((mres.pos > 100000) || (mres.match2end > 100000) || (match_len > 100000)) {
|
||||
LYXERR0("BIG LENGTHS: " << mres.pos << ", " << match_len << ", " << mres.match2end);
|
||||
match_len = 0;
|
||||
}
|
||||
@ -3144,10 +3144,6 @@ int findForwardAdv(DocIterator & cur, MatchStringAdv & match)
|
||||
while (mres.pos > 5 && (increment > 5)) {
|
||||
DocIterator old_cur = cur;
|
||||
for (int i = 0; i < increment && cur; cur.forwardPos(), i++) {
|
||||
/*
|
||||
while (cur && cur.depth() != old_cur.depth())
|
||||
cur.forwardPos();
|
||||
*/
|
||||
}
|
||||
if (! cur) {
|
||||
cur = old_cur;
|
||||
@ -3307,8 +3303,14 @@ docstring stringifyFromForSearch(FindAndReplaceOptions const & opt,
|
||||
return docstring();
|
||||
if (!opt.ignoreformat)
|
||||
return latexifyFromCursor(cur, len);
|
||||
else
|
||||
return stringifyFromCursor(cur, len);
|
||||
else {
|
||||
if (len < 0) {
|
||||
return stringifyFromCursor(cur, len);
|
||||
}
|
||||
else {
|
||||
return stringifyFromCursor(cur, len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user