+ } while(1);
+ cur = old_cur;
+ if (forwardCount > 0) {
+ LYXERR(Debug::FIND, "Forwarded " << forwardCount << " step(s) (searching for innermost match)");
+ return true;;
+ }
+ else
+ return false;
+}
+
+/** Finalize an advanced find operation, advancing the cursor to the innermost
+ ** position that matches, plus computing the length of the matching text to
+ ** be selected
+ **/
+int findAdvFinalize(DocIterator & cur, MatchStringAdv const & match, int expected_len)
+{
+ // Search the foremost position that matches (avoids find of entire math
+ // inset when match at start of it)
+ DocIterator old_cur(cur.buffer());
+ MatchResult mres;
+ int max_match;
+ if (findAdvForwardInnermost(cur)) {