]> git.lyx.org Git - features.git/commitdiff
Fixed infinite loop on backwards search when matching in nested inset(s) at begin...
authorTommaso Cucinotta <tommaso@lyx.org>
Sat, 26 Dec 2009 22:10:14 +0000 (22:10 +0000)
committerTommaso Cucinotta <tommaso@lyx.org>
Sat, 26 Dec 2009 22:10:14 +0000 (22:10 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32650 a592a061-630c-0410-9148-cb99ea01b6c8

src/lyxfind.cpp

index 2ddd6da2c523e6a64a50c927012c95c79fc05633..357a01c6b235ae19174e59a74a50cfa586ff0156 100644 (file)
@@ -1022,6 +1022,7 @@ int findBackwardsAdv(DocIterator & cur, MatchStringAdv const & match) {
                else
                        cur.pos() = cur_orig.pos();
                LYXERR(Debug::FIND, "findBackAdv2: cur: " << cur);
+               DocIterator cur_prev_iter;
                if (found_match) {
                        while (true) {
                                found_match=match(cur);
@@ -1031,12 +1032,14 @@ int findBackwardsAdv(DocIterator & cur, MatchStringAdv const & match) {
                                        int len;
                                        findMostBackwards(cur, match, len);
                                        if (&cur.inset() != &cur_orig.inset()
-                                           || !(cur.pit()==cur_orig.pit())
+                                           || !(cur.pit() == cur_orig.pit())
                                            || cur.pos() < cur_orig.pos())
                                                return len;
                                }
-                               if (cur == cur_begin)
+                               // Prevent infinite loop at begin of document
+                               if (cur == cur_begin || cur == cur_prev_iter)
                                        break;
+                               cur_prev_iter = cur;
                                cur.backwardPos();
                        };
                }