Am Dienstag, 26. Februar 2019 23:12:04 CET schrieb Kornel Benko <kor...@lyx.org>: > 1.) Open EmbeddedObjects.lyx > 2.) goto chapetr 8 Program Code Listings > 3.) move cursor before the inset Program Listing 2: > 4.) advanced search for the string Inserting (it is on the next line) > 5.) if fast found, repeat the find from the previous position > wait .... wait .... wait .... > Somehow the plain text to be examined contains the whole file > EmbeddedObjects.lyx ( ~ 74000 chars). > No wonder, the search takes that long. > > (Searching with not ignoring format does not have this problem, so OK) >
This hack cures the behaviour. But I hope, someone can find the real reason. I was unable to track it down ... Kornel
diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp index b7ab4d7..135884f 100644 --- a/src/lyxfind.cpp +++ b/src/lyxfind.cpp @@ -2920,14 +2920,13 @@ 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; 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(); MathData::const_iterator it_end = (( len == -1 || cs.pos() + len > int(md.size())) @@ -3305,12 +3304,35 @@ docstring stringifyFromForSearch(FindAndReplaceOptions const & opt, { if (cur.pos() < 0 || cur.pos() > cur.lastpos()) return docstring(); if (!opt.ignoreformat) return latexifyFromCursor(cur, len); - else - return stringifyFromCursor(cur, len); + else { + if (len < 0) { + /* hack Kornel: + * it happens if cur points to listings inset. + * The programm listing in EmbeddedObjects.lyx + * returns size of 746854 chars, while the size + * of the latexified string contains only 245 bytes. + * Clearly, the error is not here, but I could not find + * where the whole file is copied into the docstring. + */ + docstring result = stringifyFromCursor(cur, len); + if (result.size() > 10000) { + LYXERR0("Size of stringified text (" << result.size() << ") exceeds 10000"); + docstring result2 = latexifyFromCursor(cur, len); + if (result2.size() < result.size()/2) { + LYXERR0("Size of latexified text (" << result2.size() << ") is more appropriate"); + return result2; + } + } + return result; + } + else { + return stringifyFromCursor(cur, len); + } + } } FindAndReplaceOptions::FindAndReplaceOptions( docstring const & find_buf_name, bool casesensitive,
signature.asc
Description: This is a digitally signed message part.