]> git.lyx.org Git - features.git/commitdiff
Fixed bug: now, when searching backwards, after wrap-around question, if match is...
authorTommaso Cucinotta <tommaso@lyx.org>
Sat, 26 Dec 2009 22:31:59 +0000 (22:31 +0000)
committerTommaso Cucinotta <tommaso@lyx.org>
Sat, 26 Dec 2009 22:31:59 +0000 (22:31 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32651 a592a061-630c-0410-9148-cb99ea01b6c8

src/lyxfind.cpp

index 357a01c6b235ae19174e59a74a50cfa586ff0156..ed700f7da4f0b563ebca5b35c452fc0693263df3 100644 (file)
@@ -989,7 +989,11 @@ void findMostBackwards(DocIterator & cur, MatchStringAdv const & match, int & le
 int findBackwardsAdv(DocIterator & cur, MatchStringAdv const & match) {
        if (! cur)
                return 0;
+       // Backup of original position (for restoring it in case match not found)
        DocIterator cur_orig(cur);
+       // Position beyond which match is not considered
+       // (set to end of document after wrap-around question)
+       DocIterator cur_orig2(cur);
        DocIterator cur_begin = doc_iterator_begin(cur.buffer());
 /*     if (match(cur_orig)) */
 /*             findAdvFinalize(cur_orig, match); */
@@ -1020,7 +1024,7 @@ int findBackwardsAdv(DocIterator & cur, MatchStringAdv const & match) {
                if (pit_changed)
                        cur.pos() = cur.lastpos();
                else
-                       cur.pos() = cur_orig.pos();
+                       cur.pos() = cur_orig2.pos();
                LYXERR(Debug::FIND, "findBackAdv2: cur: " << cur);
                DocIterator cur_prev_iter;
                if (found_match) {
@@ -1031,9 +1035,9 @@ int findBackwardsAdv(DocIterator & cur, MatchStringAdv const & match) {
                                if (found_match) {
                                        int len;
                                        findMostBackwards(cur, match, len);
-                                       if (&cur.inset() != &cur_orig.inset()
-                                           || !(cur.pit() == cur_orig.pit())
-                                           || cur.pos() < cur_orig.pos())
+                                       if (&cur.inset() != &cur_orig2.inset()
+                                           || !(cur.pit() == cur_orig2.pit())
+                                           || cur.pos() < cur_orig2.pos())
                                                return len;
                                }
                                // Prevent infinite loop at begin of document
@@ -1051,6 +1055,8 @@ int findBackwardsAdv(DocIterator & cur, MatchStringAdv const & match) {
                        0, 1, _("&Yes"), _("&No"));
                cur = doc_iterator_end(&match.buf);
                cur.backwardPos();
+               LYXERR(Debug::FIND, "findBackAdv5: cur: " << cur);
+               cur_orig2 = cur;
        } while (wrap_answer == 0);
        cur = cur_orig;
        return 0;