]> git.lyx.org Git - lyx.git/blobdiff - src/Cursor.cpp
fix warning
[lyx.git] / src / Cursor.cpp
index 14e31f922cd4731c8b8820f6c8379df5907b8400..1ddbfa40e0b9d6c1663ca76ff2ef8ba7c4d11830 100644 (file)
@@ -1303,7 +1303,7 @@ void Cursor::niceInsert(docstring const & t, Parse::flags f)
 {
        MathData ar(buffer());
        asArray(t, ar, f);
-       if (ar.size() == 1)
+       if (ar.size() == 1 && selection())
                niceInsert(ar[0]);
        else
                insert(ar);
@@ -1314,9 +1314,10 @@ void Cursor::niceInsert(MathAtom const & t)
 {
        macroModeClose();
        docstring const safe = cap::grabAndEraseSelection(*this);
+       // Enter the new inset and, if something is selected,
+       // move the contents of the selection if possible.
        plainInsert(t);
-       // enter the new inset and move the contents of the selection if possible
-       if (t->isActive()) {
+       if (!safe.empty() && t->isActive()) {
                posBackward();
                // be careful here: don't use 'pushBackward(t)' as this we need to
                // push the clone, not the original
@@ -2163,9 +2164,9 @@ bool notifyCursorLeavesOrEnters(Cursor const & old, Cursor & cur)
        // notify everything on top of the common part in old cursor,
        // but stop if the inset claims the cursor to be invalid now
        for (size_type j = i; j < old.depth(); ++j) {
-               Cursor insetPos = old;
-               insetPos.cutOff(j);
-               if (old[j].inset().notifyCursorLeaves(insetPos, cur))
+               Cursor inset_pos = old;
+               inset_pos.cutOff(j);
+               if (old[j].inset().notifyCursorLeaves(inset_pos, cur))
                        return true;
        }