]> git.lyx.org Git - lyx.git/blobdiff - src/lyxfind.cpp
cmake: remove 2.8 warning
[lyx.git] / src / lyxfind.cpp
index 409a2e2cf7f2a1bf8d24fbf5725d111dd2311a0a..22e3b71f8f33aee94ae472eef9b32d4521d2f6c2 100644 (file)
@@ -882,8 +882,9 @@ int MatchStringAdv::findAux(DocIterator const & cur, int len, bool at_begin) con
                        // plus the last subexpression, if a (.*?) was inserted in the constructor.
                        if (!braces_match(m[0].first, m[0].second, open_braces))
                                return 0;
-                       // Check braces on segments that matched all (.*?) subexpressions.
-                       for (size_t i = 1; i < m.size(); ++i)
+                       // Check braces on segments that matched all (.*?) subexpressions,
+                       // except the last "padding" one inserted by lyx.
+                       for (size_t i = 1; i < m.size() - 1; ++i)
                                if (!braces_match(m[i].first, m[i].second))
                                        return false;
                        // Exclude from the returned match length any length 
@@ -1336,12 +1337,14 @@ static void findAdvReplace(BufferView * bv, FindAndReplaceOptions const & opt, M
                LYXERR(Debug::FIND, "Replacing by niceInsert()ing latex: '" << repl_latex << "'");
                sel_len = cur.niceInsert(repl_latex);
        }
-       cur.pos() -= sel_len;
-       if (cur.pos() < 0)
+       if (cur.pos() >= sel_len)
+               cur.pos() -= sel_len;
+       else
                cur.pos() = 0;
        LYXERR(Debug::FIND, "Putting selection at cur=" << cur << " with len: " << sel_len);
        bv->putSelectionAt(DocIterator(cur), sel_len, !opt.forward);
        bv->processUpdateFlags(Update::Force);
+       bv->buffer().updatePreviews();
 }