mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
FindAdv: Do not search in deleted text.
This commit is contained in:
parent
eab9108dc1
commit
469b43c791
@ -3622,10 +3622,10 @@ int findForwardAdv(DocIterator & cur, MatchStringAdv & match)
|
||||
else { // match_len > 0
|
||||
// Try to find the begin of searched string
|
||||
int increment;
|
||||
int firstInvalid = 100000;
|
||||
int firstInvalid = cur.lastpos() - cur.pos();
|
||||
{
|
||||
int incrmatch = (mres.match_prefix + mres.pos - mres.leadsize + 1)*3/4;
|
||||
int incrcur = (cur.lastpos() - cur.pos() + 1 )*3/4;
|
||||
int incrcur = (firstInvalid + 1 )*3/4;
|
||||
if (incrcur < incrmatch)
|
||||
increment = incrcur;
|
||||
else
|
||||
@ -3636,21 +3636,11 @@ int findForwardAdv(DocIterator & cur, MatchStringAdv & match)
|
||||
LYXERR(Debug::FIND, "Set increment to " << increment);
|
||||
while (increment > 0) {
|
||||
DocIterator old_cur = cur;
|
||||
size_t skipping = cur.depth();
|
||||
for (int i = 0; i < increment && cur; i++) {
|
||||
cur.forwardPos();
|
||||
while (cur && cur.depth() > skipping) {
|
||||
cur.pos() = cur.lastpos();
|
||||
cur.forwardPos();
|
||||
}
|
||||
}
|
||||
if (! cur || (cur.pit() > old_cur.pit())) {
|
||||
// Are we outside of the paragraph?
|
||||
// This can happen if moving past some UTF8-encoded chars
|
||||
cur = old_cur;
|
||||
if (cur.pos() + increment >= cur.lastpos()) {
|
||||
increment /= 2;
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
cur.pos() = cur.pos() + increment;
|
||||
MatchResult mres2 = match(cur, -1, false);
|
||||
displayMres(mres2, "findForwardAdv loop", cur)
|
||||
switch (interpretMatch(mres, mres2)) {
|
||||
@ -3681,9 +3671,9 @@ int findForwardAdv(DocIterator & cur, MatchStringAdv & match)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mres.match_len > 0) {
|
||||
if (mres.match_prefix + mres.pos - mres.leadsize > 0) {
|
||||
// The match seems to indicate some deeper level
|
||||
repeat = true;
|
||||
orig_cur = cur;
|
||||
orig_mres = mres;
|
||||
@ -3692,7 +3682,7 @@ int findForwardAdv(DocIterator & cur, MatchStringAdv & match)
|
||||
}
|
||||
}
|
||||
else if (repeat) {
|
||||
// seems to never be reached.
|
||||
// should never be reached.
|
||||
cur = orig_cur;
|
||||
mres = orig_mres;
|
||||
}
|
||||
|
@ -444,7 +444,7 @@ void TeXEnvironment(Buffer const & buf, Text const & text,
|
||||
if ((par->layout() != nextpar->layout()
|
||||
|| par->params().depth() == nextpar->params().depth()
|
||||
|| par->params().leftIndent() == nextpar->params().leftIndent())
|
||||
&& !runparams.for_search && !cpar.empty()
|
||||
&& !cpar.empty()
|
||||
&& cpar.isDeleted(0, cpar.size()) && !buf.params().output_changes) {
|
||||
if (!buf.params().output_changes && !cpar.parEndChange().deleted())
|
||||
os << '\n' << '\n';
|
||||
@ -759,7 +759,7 @@ void TeXOnePar(Buffer const & buf,
|
||||
|
||||
// Do not output empty commands if the whole paragraph has
|
||||
// been deleted with ct and changes are not output.
|
||||
if (!runparams_in.for_search && style.latextype != LATEX_ENVIRONMENT
|
||||
if (style.latextype != LATEX_ENVIRONMENT
|
||||
&& !par.empty() && par.isDeleted(0, par.size()) && !bparams.output_changes)
|
||||
return;
|
||||
|
||||
@ -1665,7 +1665,7 @@ void latexParagraphs(Buffer const & buf,
|
||||
if ((par->layout() != nextpar->layout()
|
||||
|| par->params().depth() == nextpar->params().depth()
|
||||
|| par->params().leftIndent() == nextpar->params().leftIndent())
|
||||
&& !runparams.for_search && !cpar.empty()
|
||||
&& !cpar.empty()
|
||||
&& cpar.isDeleted(0, cpar.size()) && !bparams.output_changes) {
|
||||
if (!cpar.parEndChange().deleted())
|
||||
os << '\n' << '\n';
|
||||
@ -1674,7 +1674,7 @@ void latexParagraphs(Buffer const & buf,
|
||||
} else {
|
||||
// This is the last par
|
||||
Paragraph const & cpar = paragraphs.at(pit);
|
||||
if (!runparams.for_search && !cpar.empty()
|
||||
if (!cpar.empty()
|
||||
&& cpar.isDeleted(0, cpar.size()) && !bparams.output_changes) {
|
||||
if (!cpar.parEndChange().deleted())
|
||||
os << '\n' << '\n';
|
||||
|
Loading…
Reference in New Issue
Block a user