]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathGrid.cpp
Revert "XHTML: remove DOCTYPE, as the document is then understood as HTML4/XHTML1...
[lyx.git] / src / mathed / InsetMathGrid.cpp
index 0a637ec715c26ae8f32d5bf4ab5f718de9d02385..3de72abcb194cd9dedb022fc108871d345a0977a 100644 (file)
@@ -1634,8 +1634,8 @@ void InsetMathGrid::doDispatch(Cursor & cur, FuncRequest & cmd)
                        for (row_type r = 0; r < numrows; ++r) {
                                for (col_type c = 0; c < numcols; ++c) {
                                        idx_type i = index(r + startrow, c + startcol);
-                                       cell(i).insert(c == 0 ? cur.pos() : 0,
-                                                      grid.cell(grid.index(r, c)));
+                                       pos_type const ipos = min(cur.pos(), pos_type(cell(i).size()));
+                                       cell(i).insert(ipos, grid.cell(grid.index(r, c)));
                                }
                                if (hline_enabled)
                                        rowinfo_[r].lines += grid.rowinfo_[r].lines;