}
}
#endif
+ theCoords.insets().add(at.nucleus(), x, y);
at->drawSelection(pi, x, y);
at->draw(pi, x, y);
x += at->width();
const_iterator it = begin();
int lastx = 0;
int currx = 0;
+ // find first position after targetx
for (; currx < targetx && it < end(); ++it) {
lastx = currx;
if ((*it)->getChar() == ' ')
currx += (*it)->width();
}
- if (abs(lastx - targetx) < abs(currx - targetx) && it != begin())
+ /**
+ * If we are not at the beginning of the array, go to the left
+ * of the inset if one of the following two condition holds:
+ * - the current inset is editable (so that the cursor tip is
+ * deeper than us): in this case, we want all intermediate
+ * cursor slices to be before insets;
+ * - the mouse is closer to the left side of the inset than to
+ * the right one.
+ * See bug 1918 for details.
+ **/
+ if (it != begin()
+ && ((*boost::prior(it))->asNestInset()
+ || abs(lastx - targetx) < abs(currx - targetx))) {
--it;
- // The below code guarantees that in this slice, the cursor will
- // never be on the right edge of an inset after a mouse click.
- if (it != begin())
- --it;
- if (it < end() && (*it)->getChar())
- ++it;
-
+ }
+
return it - begin();
}