X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FCursor.cpp;h=3fd2578f272707f21a6e1e3386c21ec75ceabfe6;hb=4ea0fd6af41beffc3eea1efcf8a0427a9d122b9c;hp=e694a13dddac879d35e442f6c31e2a652794b1b2;hpb=63be456c8d087ad3a43f20be351b36cc3b67b37a;p=lyx.git diff --git a/src/Cursor.cpp b/src/Cursor.cpp index e694a13ddd..3fd2578f27 100644 --- a/src/Cursor.cpp +++ b/src/Cursor.cpp @@ -1906,10 +1906,13 @@ bool Cursor::upDownInText(bool up, bool & updateNeeded) int yo = bv().getPos(*this).y_; Cursor old = *this; // To next/previous row + // FIXME: the y position is often guessed wrongly across styles and + // insets, which leads to weird behaviour. if (up) tm.editXY(*this, xo, yo - textRow().ascent() - 1); else tm.editXY(*this, xo, yo + textRow().descent() + 1); + x_target_ = old.x_target_; clearSelection(); // This happens when you move out of an inset. @@ -2425,8 +2428,8 @@ bool Cursor::confirmDeletion(bool const before) const return inset->confirmDeletion(); } else { DocIterator dit = selectionBegin(); - DocIterator const sel_end = selectionEnd(); - for (; dit < sel_end; dit.posForward()) + CursorSlice const end = selectionEnd().top(); + for (; dit.top() < end; dit.top().forwardPos()) if (Inset const * inset = dit.nextInset()) if (inset->confirmDeletion()) return true; @@ -2443,6 +2446,8 @@ void Cursor::moveToClosestEdge(int const x, bool const edit) if (edit && (inset->hasSettings() || !inset->contextMenuName().empty())) return; CoordCache::Insets const & insetCache = bv().coordCache().getInsets(); + if (!insetCache.has(inset)) + return; int const wid = insetCache.dim(inset).wid; Point p = insetCache.xy(inset); if (x > p.x_ + (wid + 1) / 2)