From 67503f8fe139acdf3ff8ce7c0b44cd81240767ac Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Wed, 15 Apr 2009 22:07:59 +0000 Subject: [PATCH] Fix the bug that when pressing the merge button while in the middle of a change, only half of the change was found. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29250 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/lyxfind.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp index 6fa6aade1f..278f81c262 100644 --- a/src/lyxfind.cpp +++ b/src/lyxfind.cpp @@ -360,6 +360,20 @@ bool findChange(BufferView * bv, bool next) } DocIterator cur = bv->cursor(); + + // 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; + if (cur.pos() > 1) { + Change change_next_pos + = cur.paragraph().lookupChange(cur.pos()); + Change change_prev_pos + = cur.paragraph().lookupChange(cur.pos() - 1); + if (change_next_pos.isSimilarTo(change_prev_pos)) + search_both_sides = true; + } + if (!findChange(cur, next)) return false; @@ -394,6 +408,11 @@ bool findChange(BufferView * bv, bool next) bv->cursor().setCursor(cur); bv->cursor().setSelection(); + if (search_both_sides) { + bv->cursor().setSelection(false); + findChange(bv, !next); + } + return true; } -- 2.39.2