X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FCursor.cpp;h=0017e1ae149576b29cdc42ccf9475156691dc127;hb=2098f1d8c20d51e63e670bcdc9da8996068975bf;hp=5e8843245f89ec0e298d3309ce5c5eb2b97cdd25;hpb=c2befc2b1e9961ad75d799b05c9fb201a73675a5;p=lyx.git diff --git a/src/Cursor.cpp b/src/Cursor.cpp index 5e8843245f..0017e1ae14 100644 --- a/src/Cursor.cpp +++ b/src/Cursor.cpp @@ -254,8 +254,8 @@ bool bruteFind3(Cursor & cur, int x, int y, bool up) Cursor::Cursor(BufferView & bv) : DocIterator(&bv.buffer()), bv_(&bv), anchor_(), x_target_(-1), textTargetOffset_(0), - selection_(false), mark_(false), logicalpos_(false), - current_font(inherit_font) + selection_(false), mark_(false), word_selection_(false), + logicalpos_(false), current_font(inherit_font) {} @@ -483,8 +483,14 @@ void Cursor::resetAnchor() void Cursor::setCursorToAnchor() { - if (selection()) - setCursor(anchor_); + if (selection()) { + DocIterator normal = anchor_; + while (depth() < normal.depth()) + normal.pop_back(); + if (depth() < anchor_.depth() && top() <= anchor_[depth() - 1]) + ++normal.pos(); + setCursor(normal); + } } @@ -1059,6 +1065,7 @@ void Cursor::setSelection(DocIterator const & where, int n) void Cursor::clearSelection() { setSelection(false); + setWordSelection(false); setMark(false); resetAnchor(); } @@ -1303,7 +1310,7 @@ void Cursor::niceInsert(docstring const & t, Parse::flags f, bool enter) { MathData ar(buffer()); asArray(t, ar, f); - if (ar.size() == 1 && (selection() || enter)) + if (ar.size() == 1 && (enter || selection())) niceInsert(ar[0]); else insert(ar);