From: Tommaso Cucinotta Date: Sat, 26 Dec 2009 22:31:59 +0000 (+0000) Subject: Fixed bug: now, when searching backwards, after wrap-around question, if match is... X-Git-Tag: 2.0.0~4702 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=6675847986d4fbd8f240a41b6ad929476aef7dc8;p=features.git Fixed bug: now, when searching backwards, after wrap-around question, if match is beyond the cursor position then it is correctly found. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32651 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp index 357a01c6b2..ed700f7da4 100644 --- a/src/lyxfind.cpp +++ b/src/lyxfind.cpp @@ -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;