X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Flyxfind.cpp;h=269b2123707207bbdb095a0db123ff1fdd87ef0f;hb=4db3e641ed6765e005343010cb90ee8af26f8f99;hp=308074c3a9ca06e3757ef8f879e28ee0b422f812;hpb=d79225ae987164c59d92621f5f7de203d3179c4c;p=lyx.git diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp index 308074c3a9..269b212370 100644 --- a/src/lyxfind.cpp +++ b/src/lyxfind.cpp @@ -45,6 +45,7 @@ #include "support/convert.h" #include "support/debug.h" #include "support/docstream.h" +#include "support/FileName.h" #include "support/gettext.h" #include "support/lassert.h" #include "support/lstrings.h" @@ -121,23 +122,6 @@ int findBackwards(DocIterator & cur, MatchString const & match, } -bool findChange(DocIterator & cur, bool next) -{ - if (!next) - cur.backwardPos(); - for (; cur; next ? cur.forwardPos() : cur.backwardPos()) - if (cur.inTexted() && cur.paragraph().isChanged(cur.pos())) { - if (!next) - // if we search backwards, take a step forward - // to correctly set the anchor - cur.forwardPos(); - return true; - } - - return false; -} - - bool searchAllowed(docstring const & str) { if (str.empty()) { @@ -404,15 +388,21 @@ bool lyxreplace(BufferView * bv, } -bool findNextChange(BufferView * bv) +namespace { +bool findChange(DocIterator & cur, bool next) { - return findChange(bv, true); -} - + if (!next) + cur.backwardPos(); + for (; cur; next ? cur.forwardPos() : cur.backwardPos()) + if (cur.inTexted() && cur.paragraph().isChanged(cur.pos())) { + if (!next) + // if we search backwards, take a step forward + // to correctly set the anchor + cur.forwardPos(); + return true; + } -bool findPreviousChange(BufferView * bv) -{ - return findChange(bv, false); + return false; } @@ -456,13 +446,13 @@ bool findChange(BufferView * bv, bool next) Change orig_change = tip.paragraph().lookupChange(tip.pos()); if (next) { - for (; !tip.at_end(); tip.forwardPos()) { + for (; tip.pit() < tip.lastpit() || tip.pos() < tip.lastpos(); tip.forwardPos()) { Change change = tip.paragraph().lookupChange(tip.pos()); if (!change.isSimilarTo(orig_change)) break; } } else { - for (; !tip.at_begin();) { + for (; tip.pit() > 0 || tip.pos() > 0;) { tip.backwardPos(); Change change = tip.paragraph().lookupChange(tip.pos()); if (!change.isSimilarTo(orig_change)) { @@ -483,6 +473,20 @@ bool findChange(BufferView * bv, bool next) return true; } +} + + +bool findNextChange(BufferView * bv) +{ + return findChange(bv, true); +} + + +bool findPreviousChange(BufferView * bv) +{ + return findChange(bv, false); +} + namespace {