]> git.lyx.org Git - features.git/commitdiff
Fix bug #2213 (part 5): GuiChanges lacks "Previous Change" button.
authorVincent van Ravesteijn <vfr@lyx.org>
Sun, 5 Apr 2009 20:16:32 +0000 (20:16 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Sun, 5 Apr 2009 20:16:32 +0000 (20:16 +0000)
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

src/Cursor.cpp
src/Cursor.h
src/lyxfind.cpp

index 91402c3396211d227e3878ca1607560064fd05e1..afa8a9b30ffaa5ad36db6cccd198fe5405b51645 100644 (file)
@@ -426,6 +426,12 @@ void Cursor::resetAnchor()
 }
 
 
+void Cursor::setCursorToAnchor()
+{
+       if (selection())
+               setCursor(anchor_);
+}
+
 
 bool Cursor::posBackward()
 {
index 276bf2e989968e80e33fe5dd240510278da66784..81b2d9b97e472df9ba9c64c6b3f72127947ef2e6 100644 (file)
@@ -63,6 +63,8 @@ public:
        void leaveInset(Inset const & inset);
        /// sets cursor part
        void setCursor(DocIterator const & it);
+       /// sets the cursor to the anchor
+       void setCursorToAnchor();
 
        ///
        void setCurrentFont();
index 40e503e5f9d8a0a83c76c242ee431e7978a6bd43..6fa6aade1f459be41411005c503239b5bd763104 100644 (file)
@@ -352,6 +352,13 @@ 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().anchor())
+                       bv->cursor().setCursorToAnchor();
+       }
+
        DocIterator cur = bv->cursor();
        if (!findChange(cur, next))
                return false;