]> git.lyx.org Git - lyx.git/blobdiff - src/CutAndPaste.C
Fix #1736
[lyx.git] / src / CutAndPaste.C
index 76bb471f8288dc84ecffa1761e820ab30ba981b9..acdc5e763811bcb931af3cd68dbbd3dd43f12fd0 100644 (file)
@@ -170,7 +170,7 @@ pasteSelectionHelper(Buffer const & buffer, ParagraphList & pars,
                        switch (lit->inset->lyxCode()) {
                        case InsetOld::TABULAR_CODE: {
                                InsetTabular * it = static_cast<InsetTabular*>(lit->inset);
-                               it->buffer(const_cast<Buffer*>(&buffer));
+                               it->buffer(&buffer);
                                break;
                        }
 
@@ -601,14 +601,15 @@ void replaceSelectionWithString(LCursor & cur, string const & str)
 
        // Get font setting before we cut
        pos_type pos = cur.selEnd().pos();
-       LyXFont const font = text->getPar(cur.selBegin().par()).
-               getFontSettings(cur.buffer().params(), cur.selBegin().pos());
+       Paragraph & par = text->getPar(cur.selEnd().par());
+       LyXFont const font =
+               par.getFontSettings(cur.buffer().params(), cur.selBegin().pos());
 
        // Insert the new string
        string::const_iterator cit = str.begin();
        string::const_iterator end = str.end();
        for (; cit != end; ++cit, ++pos)
-               text->getPar(cur.selEnd().par()).insertChar(pos, (*cit), font);
+               par.insertChar(pos, (*cit), font);
 
        // Cut the selection
        cutSelection(cur, true, false);
@@ -639,12 +640,9 @@ void replaceWord(LCursor & cur, string const & replacestring)
 
 void eraseSelection(LCursor & cur)
 {
-       //lyxerr << "LCursor::eraseSelection" << endl;
+       //lyxerr << "LCursor::eraseSelection begin: " << cur << endl;
        CursorSlice const & i1 = cur.selBegin();
        CursorSlice const & i2 = cur.selEnd();
-#ifdef WITH_WARNINGS
-#warning FIXME
-#endif
        if (i1.inset().asMathInset()) {
                if (i1.idx() == i2.idx()) {
                        i1.cell().erase(i1.pos(), i2.pos());
@@ -658,10 +656,12 @@ void eraseSelection(LCursor & cur)
                                        p->cell(p->index(row, col)).clear();
                }
                cur.back() = i1;
+               cur.pos() = 0; // We've deleted the whole cell. Only pos 0 is valid.
+               cur.resetAnchor();
        } else {
                lyxerr << "can't erase this selection 1" << endl;
        }
-       //lyxerr << "LCursor::eraseSelection end" << endl;
+       //lyxerr << "LCursor::eraseSelection end: " << cur << endl;
 }