mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Fix bug #3199: change-next may leave empty lines behind
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...).
This commit is contained in:
parent
959d2c5264
commit
77bf805155
@ -417,20 +417,15 @@ bool findPreviousChange(BufferView * bv)
|
|||||||
|
|
||||||
bool findChange(BufferView * bv, bool next)
|
bool findChange(BufferView * bv, bool next)
|
||||||
{
|
{
|
||||||
if (bv->cursor().selection()) {
|
Cursor cur(*bv);
|
||||||
// set the cursor at the beginning or at the end of the selection
|
cur.setCursor(next ? bv->cursor().selectionEnd()
|
||||||
// before searching. Otherwise, the current change will be found.
|
: bv->cursor().selectionBegin());
|
||||||
if (next != (bv->cursor().top() > bv->cursor().normalAnchor()))
|
|
||||||
bv->cursor().setCursorToAnchor();
|
|
||||||
}
|
|
||||||
|
|
||||||
DocIterator cur = bv->cursor();
|
|
||||||
|
|
||||||
// Are we within a change ? Then first search forward (backward),
|
// Are we within a change ? Then first search forward (backward),
|
||||||
// clear the selection and search the other way around (see the end
|
// clear the selection and search the other way around (see the end
|
||||||
// of this function). This will avoid changes to be selected half.
|
// of this function). This will avoid changes to be selected half.
|
||||||
bool search_both_sides = false;
|
bool search_both_sides = false;
|
||||||
DocIterator tmpcur = cur;
|
Cursor tmpcur = cur;
|
||||||
// Leave math first
|
// Leave math first
|
||||||
while (tmpcur.inMathed())
|
while (tmpcur.inMathed())
|
||||||
tmpcur.pop_back();
|
tmpcur.pop_back();
|
||||||
@ -449,8 +444,7 @@ bool findChange(BufferView * bv, bool next)
|
|||||||
if (!findChange(cur, next))
|
if (!findChange(cur, next))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bv->cursor().setCursor(cur);
|
bv->mouseSetCursor(cur, false);
|
||||||
bv->cursor().resetAnchor();
|
|
||||||
|
|
||||||
CursorSlice & tip = cur.top();
|
CursorSlice & tip = cur.top();
|
||||||
|
|
||||||
@ -478,12 +472,11 @@ bool findChange(BufferView * bv, bool next)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now put cursor to end of selection:
|
if (!search_both_sides) {
|
||||||
bv->cursor().setCursor(cur);
|
// Now set the selection.
|
||||||
bv->cursor().setSelection();
|
bv->mouseSetCursor(cur, true);
|
||||||
|
} else {
|
||||||
if (search_both_sides) {
|
bv->mouseSetCursor(cur, false);
|
||||||
bv->cursor().setSelection(false);
|
|
||||||
findChange(bv, !next);
|
findChange(bv, !next);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user