]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetTabular.cpp
Fix crash after undo following replacement of a multicell selection (#8973).
[lyx.git] / src / insets / InsetTabular.cpp
index b633c492e1b6175180ea4b82c5517821c375ef50..b12474344606c04db87920a5ca81e3f92c5408a4 100644 (file)
@@ -3432,6 +3432,12 @@ docstring InsetTableCell::asString(bool intoInsets)
 }
 
 
+void InsetTableCell::addToToc(DocIterator const & di, bool output_active) const
+{
+       InsetText::iterateForToc(di, output_active);
+}
+
+
 docstring InsetTableCell::xhtml(XHTMLStream & xs, OutputParams const & rp) const
 {
        if (!isFixedWidth)
@@ -3897,8 +3903,12 @@ void InsetTabular::updateBuffer(ParIterator const & it, UpdateType utype)
        // In a longtable, tell captions what the current float is
        Counters & cnts = buffer().masterBuffer()->params().documentClass().counters();
        string const saveflt = cnts.current_float();
-       if (tabular.is_long_tabular)
+       if (tabular.is_long_tabular) {
                cnts.current_float("table");
+               // in longtables, we only step the counter once
+               cnts.step(from_ascii("table"), utype);
+               cnts.isLongtable(true);
+       }
 
        ParIterator it2 = it;
        it2.forwardPos();
@@ -3907,8 +3917,10 @@ void InsetTabular::updateBuffer(ParIterator const & it, UpdateType utype)
                buffer().updateBuffer(it2, utype);
 
        //reset afterwards
-       if (tabular.is_long_tabular)
+       if (tabular.is_long_tabular) {
                cnts.current_float(saveflt);
+               cnts.isLongtable(false);
+       }
 }
 
 
@@ -4316,8 +4328,16 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd)
                if (cur.selIsMultiCell()) {
                        cur.recordUndoInset(DELETE_UNDO);
                        cutSelection(cur);
-               }
-               cell(cur.idx())->dispatch(cur, cmd);
+                       BufferView * bv = &cur.bv();
+                       docstring::const_iterator cit = cmd.argument().begin();
+                       docstring::const_iterator const end = cmd.argument().end();
+                       for (; cit != end; ++cit)
+                               bv->translateAndInsert(*cit, getText(cur.idx()), cur);
+       
+                       cur.resetAnchor();
+                       bv->bookmarkEditPosition();
+               } else
+                       cell(cur.idx())->dispatch(cur, cmd);
                break;
 
        case LFUN_CHAR_DELETE_BACKWARD: