- getLyXText(bv)->setCursorFromCoordinates(bv, x-drawTextXOffset,
- y + insetAscent);
- getLyXText(bv)->clearSelection();
- updateLocal(bv, FULL, false);
- getLyXText(bv)->selection.cursor = getLyXText(bv)->cursor;
+ bool clear = false;
+ if (!lt) {
+ lt = getLyXText(bv);
+ clear = true;
+ }
+ lt->setCursorFromCoordinates(bv, x-drawTextXOffset, y + insetAscent);
+ if (lt->selection.set()) {
+ lt->clearSelection();
+ updateLocal(bv, FULL, false);
+ } else {
+ lt->clearSelection();
+ }