commit 3f373a637d6f17f6974d1ddb719a0973cfba66f8
Author: Juergen Spitzmueller <[email protected]>
Date:   Fri Nov 7 14:44:05 2025 +0100

    More fixes to plaintext table paste
    
    (cherry picked from commit 82be79516594b0e4d25a8ac0877be1b6a8d64aa4)
---
 src/insets/InsetTabular.cpp | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp
index fc20b93cca..a4e8603338 100644
--- a/src/insets/InsetTabular.cpp
+++ b/src/insets/InsetTabular.cpp
@@ -8405,7 +8405,7 @@ bool InsetTabular::insertPlaintextString(BufferView & bv, 
docstring const & buf,
        p = 0;
        cols = ocol;
        rows = loctab->nrows();
-       col_type columns = loctab->ncols();
+       col_type lastcol = loctab->ncols() - 1;
 
        while (p < len &&
               (p = buf.find_first_of(from_ascii("\t\n"), p)) != 
docstring::npos)
@@ -8415,13 +8415,13 @@ bool InsetTabular::insertPlaintextString(BufferView & 
bv, docstring const & buf,
                switch (buf[p]) {
                case '\t':
                        // append column if necessary
-                       if (cols == columns) {
-                               loctab->appendColumn(cols - 1);
-                               columns = loctab->ncols();
+                       if (cols == lastcol) {
+                               loctab->appendColumn(cols, row);
+                               lastcol = loctab->ncols() - 1;
                                cells = loctab->numberofcells;
-                               ++cell;
+                               cell = loctab->cellIndex(row, cols);
                        }
-                       if (cols < columns) {
+                       if (cols <= lastcol) {
                                shared_ptr<InsetTableCell> inset = 
loctab->cellInset(cell);
                                Font const font = 
bv.textMetrics(&inset->text()).
                                        displayFont(0, 0);
@@ -8433,7 +8433,7 @@ bool InsetTabular::insertPlaintextString(BufferView & bv, 
docstring const & buf,
                        break;
                case '\n':
                        // we can only set this if we are not too far right
-                       if (cols < columns) {
+                       if (cols <= lastcol) {
                                shared_ptr<InsetTableCell> inset = 
tabular.cellInset(cell);
                                Font const font = 
bv.textMetrics(&inset->text()).
                                        displayFont(0, 0);
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to