]> git.lyx.org Git - lyx.git/blobdiff - src/Cursor.cpp
fix warning
[lyx.git] / src / Cursor.cpp
index aa669c04f86c5c9ced631a3a4cc42adeb93b025f..92b9110ba7629b9b7215acae81e3296df281be48 100644 (file)
@@ -944,7 +944,14 @@ DocIterator Cursor::selectionBegin() const
 {
        if (!selection())
                return *this;
-       DocIterator di = (anchor() < top() ? anchor_ : *this);
+
+       DocIterator di;
+       // FIXME: This is a work-around for the problem that
+       // CursorSlice doesn't keep track of the boundary.
+       if (anchor() == top())
+               di = anchor_.boundary() > boundary() ? anchor_ : *this;
+       else
+               di = anchor() < top() ? anchor_ : *this;
        di.resize(depth());
        return di;
 }
@@ -954,7 +961,15 @@ DocIterator Cursor::selectionEnd() const
 {
        if (!selection())
                return *this;
-       DocIterator di = (anchor() > top() ? anchor_ : *this);
+
+       DocIterator di;
+       // FIXME: This is a work-around for the problem that
+       // CursorSlice doesn't keep track of the boundary.
+       if (anchor() == top())
+               di = anchor_.boundary() < boundary() ? anchor_ : *this;
+       else
+               di = anchor() > top() ? anchor_ : *this;
+
        if (di.depth() > depth()) {
                di.resize(depth());
                ++di.pos();
@@ -1814,6 +1829,8 @@ void Cursor::handleFont(string const & font)
                safe = cap::grabAndEraseSelection(*this);
        }
 
+       recordUndoInset();
+
        if (lastpos() != 0) {
                // something left in the cell
                if (pos() == 0) {
@@ -1833,8 +1850,9 @@ void Cursor::handleFont(string const & font)
                }
        } else {
                // nothing left in the cell
-               pullArg();
+               popBackward();
                plainErase();
+               resetAnchor();
        }
        insert(safe);
 }
@@ -2117,6 +2135,18 @@ void Cursor::finishUndo() const
 }
 
 
+void Cursor::beginUndoGroup() const
+{
+       bv_->buffer().undo().beginUndoGroup();
+}
+
+
+void Cursor::endUndoGroup() const
+{
+       bv_->buffer().undo().endUndoGroup();
+}
+
+
 void Cursor::recordUndo(UndoKind kind, pit_type from, pit_type to) const
 {
        bv_->buffer().undo().recordUndo(*this, kind, from, to);