- 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;
- DocIterator tmpcur = cur;
- // Leave math first
- while (tmpcur.inMathed())
- tmpcur.pop_back();
- Change change_next_pos
- = tmpcur.paragraph().lookupChange(tmpcur.pos());
- if (change_next_pos.changed() && cur.inMathed()) {
- cur = tmpcur;
- search_both_sides = true;
- } else if (tmpcur.pos() > 0 && tmpcur.inTexted()) {
- Change change_prev_pos
- = tmpcur.paragraph().lookupChange(tmpcur.pos() - 1);
- if (change_next_pos.isSimilarTo(change_prev_pos))
- search_both_sides = true;
+ CursorSlice tip1 = cur.top();
+ for (; tip1.pit() < tip1.lastpit() || tip1.pos() < tip1.lastpos(); tip1.forwardPos()) {
+ Change ch2 = tip1.paragraph().lookupChange(tip1.pos());
+ if (!ch2.isSimilarTo(ch))
+ break;