]> git.lyx.org Git - lyx.git/blobdiff - src/lyxfind.cpp
Exporter.cpp: revert r34230 because this interferes with Enrico's new LyXVC feature...
[lyx.git] / src / lyxfind.cpp
index b615ff69838ed9cd7da853b39e3118848aa0862b..fd44187104fdb9a6d80ed04f18cb54c0875f562b 100644 (file)
@@ -171,6 +171,8 @@ int replaceAll(BufferView * bv,
        if (!searchAllowed(bv, searchstr) || buf.isReadonly())
                return 0;
 
+       DocIterator cur_orig(bv->cursor());
+
        MatchString const match(searchstr, cs, mw);
        int num = 0;
 
@@ -198,6 +200,10 @@ int replaceAll(BufferView * bv,
        bv->putSelectionAt(doc_iterator_begin(&buf), 0, false);
        if (num)
                buf.markDirty();
+
+       cur_orig.fixIfBroken();
+       bv->setCursor(cur_orig);
+
        return num;
 }
 
@@ -279,7 +285,7 @@ docstring const replace2string(docstring const & replace,
 
 bool find(BufferView * bv, FuncRequest const & ev)
 {
-       if (!bv || ev.action != LFUN_WORD_FIND)
+       if (!bv || ev.action() != LFUN_WORD_FIND)
                return false;
 
        //lyxerr << "find called, cmd: " << ev << endl;
@@ -300,7 +306,7 @@ bool find(BufferView * bv, FuncRequest const & ev)
 
 void replace(BufferView * bv, FuncRequest const & ev, bool has_deleted)
 {
-       if (!bv || ev.action != LFUN_WORD_REPLACE)
+       if (!bv || ev.action() != LFUN_WORD_REPLACE)
                return;
 
        // data is of the form
@@ -365,7 +371,7 @@ bool findChange(BufferView * bv, bool next)
        if (bv->cursor().selection()) {
                // set the cursor at the beginning or at the end of the selection
                // before searching. Otherwise, the current change will be found.
-               if (next != (bv->cursor().top() > bv->cursor().anchor()))
+               if (next != (bv->cursor().top() > bv->cursor().normalAnchor()))
                        bv->cursor().setCursorToAnchor();
        }