]> git.lyx.org Git - lyx.git/blobdiff - src/Cursor.cpp
Two places where coverity urges us to limit string length
[lyx.git] / src / Cursor.cpp
index 2de42ba8ad63967584dfb40084446132ab7a90c2..3fd2578f272707f21a6e1e3386c21ec75ceabfe6 100644 (file)
@@ -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.
@@ -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)