]> git.lyx.org Git - features.git/commitdiff
Fix bug #3199: change-next may leave empty lines behind
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 24 Apr 2013 10:04:49 +0000 (12:04 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 8 May 2013 10:28:56 +0000 (12:28 +0200)
Using Cursor::setCursor or even BufferView::setCursor is often a bad
idea since it does not run DEPM. In this case (and other cases in
f&replace code) it is better to use BufferView::mouseSetCursor (which
should maybe be renamed...).

src/lyxfind.cpp
status.20x

index a4ae87093026c5d52469ced869340faaf36b72a5..862d01096bb630307238c2e162036901051bcc05 100644 (file)
@@ -412,20 +412,15 @@ bool findPreviousChange(BufferView * bv)
 
 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().normalAnchor()))
-                       bv->cursor().setCursorToAnchor();
-       }
-
-       DocIterator cur = bv->cursor();
+       Cursor cur(*bv);
+       cur.setCursor(next ? bv->cursor().selectionEnd()
+                     : bv->cursor().selectionBegin());
 
        // Are we within a change ? Then first search forward (backward),
        // clear the selection and search the other way around (see the end
        // of this function). This will avoid changes to be selected half.
        bool search_both_sides = false;
-       DocIterator tmpcur = cur;
+       Cursor tmpcur = cur;
        // Leave math first
        while (tmpcur.inMathed())
                tmpcur.pop_back();
@@ -444,8 +439,7 @@ bool findChange(BufferView * bv, bool next)
        if (!findChange(cur, next))
                return false;
 
-       bv->cursor().setCursor(cur);
-       bv->cursor().resetAnchor();
+       bv->mouseSetCursor(cur, false);
 
        CursorSlice & tip = cur.top();
 
@@ -473,12 +467,11 @@ bool findChange(BufferView * bv, bool next)
                }
        }
 
-       // Now put cursor to end of selection:
-       bv->cursor().setCursor(cur);
-       bv->cursor().setSelection();
-
-       if (search_both_sides) {
-               bv->cursor().setSelection(false);
+       if (!search_both_sides) {
+               // Now set the selection.
+               bv->mouseSetCursor(cur, true);
+       } else {
+               bv->mouseSetCursor(cur, false);
                findChange(bv, !next);
        }
 
index 922ea2df1f122b53b7657747568f70c2c775c7bf..146ccdaa1ffe32938a1c47b5e8f2f6268a697142 100644 (file)
@@ -58,6 +58,8 @@ What's new
 
 - Fix crash when saving document with module that is not present (bug 8523).
 
+- Fix bug where searching for next change may leave an empty paragraph
+  where cursor was (bug 3199).
 
 * DOCUMENTATION AND LOCALIZATION