From 3b895bb47a69c41581415f262c9d197333941b73 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Mon, 29 Jun 2020 16:30:49 +0200 Subject: [PATCH] Fix math grid paste when needing more cells --- src/mathed/InsetMathGrid.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/mathed/InsetMathGrid.cpp b/src/mathed/InsetMathGrid.cpp index 52283b576b..1fd445995c 100644 --- a/src/mathed/InsetMathGrid.cpp +++ b/src/mathed/InsetMathGrid.cpp @@ -1624,8 +1624,10 @@ void InsetMathGrid::doDispatch(Cursor & cur, FuncRequest & cmd) } else { // multiple cells cur.recordUndoInset(); + col_type startcol = col(cur.idx()); + row_type startrow = cur.row(); col_type const numcols = - min(grid.ncols(), ncols() - col(cur.idx())); + min(grid.ncols(), ncols() - startcol); row_type const numrows = min(grid.nrows(), nrows() - cur.row()); for (row_type r = 0; r < numrows; ++r) { @@ -1643,19 +1645,22 @@ void InsetMathGrid::doDispatch(Cursor & cur, FuncRequest & cmd) MathAtom(new InsetMathUnknown(from_ascii("\\hline")))); } } - // append the left over horizontal cells to the last column - idx_type i = index(r + cur.row(), ncols() - 1); - for (InsetMath::col_type c = numcols; c < grid.ncols(); ++c) + // append columns for the left over horizontal cells + for (InsetMath::col_type c = numcols; c < grid.ncols(); ++c) { + addCol(c + 1); + idx_type i = index(r + cur.row(), c + 1); cell(i).append(grid.cell(grid.index(r, c))); + } } - // append the left over vertical cells to the last _cell_ + // append rows for the left over vertical cells idx_type i = nargs() - 1; for (row_type r = numrows; r < grid.nrows(); ++r) { - addRow(r - 1); + row_type crow = startrow + r; + addRow(crow - 1); for (col_type c = 0; c < grid.ncols(); ++c) - cell(index(r, c)).append(grid.cell(grid.index(r, c))); + cell(index(crow, c + startcol)).append(grid.cell(grid.index(r, c))); if (hline_enabled) - rowinfo_[r].lines += grid.rowinfo_[r].lines; + rowinfo_[crow].lines += grid.rowinfo_[r].lines; else { for (unsigned int l = 0; l < grid.rowinfo_[r].lines; ++l) { cell(i).insert(0, -- 2.39.5