]> git.lyx.org Git - lyx.git/blobdiff - src/Cursor.cpp
Make the fake sequence for braces highly unlikely (addressing #6478).
[lyx.git] / src / Cursor.cpp
index a2fb6b9420b80f636837b6474299b87d0cc80229..acc3f0e8e59a4d3b783bd94003371dac0f532c73 100644 (file)
@@ -336,8 +336,10 @@ void Cursor::dispatch(FuncRequest const & cmd0)
                LYXERR(Debug::DEBUG, "Cursor::dispatch: (AtPoint) cmd: "
                        << cmd0 << endl << *this);
                nextInset()->dispatch(*this, tmpcmd);
-               if (result().dispatched())
+               if (result().dispatched()) {
+                       buffer()->undo().endUndoGroup();
                        return;
+               }
        }
 
        // store some values to be used inside of the handlers
@@ -483,8 +485,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);
+       }
 }
 
 
@@ -1337,6 +1345,8 @@ void Cursor::insert(MathData const & ar)
                cap::eraseSelection(*this);
        cell().insert(pos(), ar);
        pos() += ar.size();
+       // FIXME audit setBuffer/updateLabels calls
+       inset().setBuffer(bv_->buffer());
 }
 
 
@@ -2136,9 +2146,12 @@ Font Cursor::getFont() const
 
 bool Cursor::fixIfBroken()
 {
-       if (DocIterator::fixIfBroken()) {
-                       clearSelection();
-                       return true;
+       bool const broken_cursor = DocIterator::fixIfBroken();
+       bool const broken_anchor = anchor_.fixIfBroken();
+       
+       if (broken_cursor || broken_anchor) {
+               clearSelection();
+               return true;
        }
        return false;
 }