Fix bug #2213 (part 5): GuiChanges lacks "Previous Change" button.

Make sure we jump to the next or previous change when we switch search direction. Without this patch, the same Change will be found and only the cursor is moved from the end (or begin) to the begin (or end) of the selection.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29115 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Vincent van Ravesteijn 2009-04-05 20:16:32 +00:00
parent a97b097768
commit 326a035a5b
3 changed files with 15 additions and 0 deletions

View File

@ -426,6 +426,12 @@ void Cursor::resetAnchor()
} }
void Cursor::setCursorToAnchor()
{
if (selection())
setCursor(anchor_);
}
bool Cursor::posBackward() bool Cursor::posBackward()
{ {

View File

@ -63,6 +63,8 @@ public:
void leaveInset(Inset const & inset); void leaveInset(Inset const & inset);
/// sets cursor part /// sets cursor part
void setCursor(DocIterator const & it); void setCursor(DocIterator const & it);
/// sets the cursor to the anchor
void setCursorToAnchor();
/// ///
void setCurrentFont(); void setCurrentFont();

View File

@ -352,6 +352,13 @@ bool findPreviousChange(BufferView * bv)
bool findChange(BufferView * bv, bool next) 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())
bv->cursor().setCursorToAnchor();
}
DocIterator cur = bv->cursor(); DocIterator cur = bv->cursor();
if (!findChange(cur, next)) if (!findChange(cur, next))
return false; return false;