]> git.lyx.org Git - lyx.git/blobdiff - src/Cursor.cpp
cleanup error messages
[lyx.git] / src / Cursor.cpp
index 2a6d4e6420688226b4b3fe8b8f6644570c0ab230..c12d054ee79019c4bc73042cc20fc21d9cc40ee5 100644 (file)
@@ -1299,11 +1299,11 @@ void Cursor::insert(Inset * inset0)
 }
 
 
-void Cursor::niceInsert(docstring const & t, Parse::flags f)
+void Cursor::niceInsert(docstring const & t, Parse::flags f, bool enter)
 {
        MathData ar(buffer());
        asArray(t, ar, f);
-       if (ar.size() == 1)
+       if (ar.size() == 1 && (enter || selection()))
                niceInsert(ar[0]);
        else
                insert(ar);
@@ -1315,7 +1315,7 @@ void Cursor::niceInsert(MathAtom const & t)
        macroModeClose();
        docstring const safe = cap::grabAndEraseSelection(*this);
        plainInsert(t);
-       // enter the new inset and move the contents of the selection if possible
+       // If possible, enter the new inset and move the contents of the selection
        if (t->isActive()) {
                posBackward();
                // be careful here: don't use 'pushBackward(t)' as this we need to
@@ -1914,8 +1914,16 @@ bool Cursor::upDownInText(bool up, bool & updateNeeded)
                }
                top().pos() = min(tm.x2pos(pit(), next_row, xo), top().lastpos());
 
-               boundary(tm.x2pos(pit(), next_row, xo) 
-                       == tm.x2pos(pit(), next_row, tm.width()));
+               int const xpos = tm.x2pos(pit(), next_row, xo);
+               bool const at_end_row = xpos == tm.x2pos(pit(), next_row, tm.width());
+               bool const at_beg_row = xpos == tm.x2pos(pit(), next_row, 0);
+
+               if (at_end_row && at_beg_row)
+                       // make sure the cursor ends up on this row
+                       boundary(false);
+               else
+                       boundary(at_end_row);
+
                updateNeeded |= bv().checkDepm(*this, old);
        }
 
@@ -2155,9 +2163,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;
        }