On Thu, 11 Oct 2007 11:55:13 +0300
Martin Vermeer <[EMAIL PROTECTED]> wrote:

> 
> 
> void InsetMathGrid::addCol(col_type newcol)
> {
>         const col_type nc = ncols();
>         const row_type nr = nrows();
>         cells_type new_cells((nc + 1) * nr);
>         vector<CellInfo> new_cellinfo((nc + 1) * nr);
> 
>         for (row_type row = 0; row < nr; ++row)
>                 for (col_type col = 0; col < nc; ++col) {
>                         new_cells[row * (nc + 1) + col + (col > newcol)]      
> <---
>                                 = cells_[row * nc + col];
>                         new_cellinfo[row * (nc + 1) + col + (col > newcol)]   
> <---
>                                 = cellinfo_[row * nc + col];
>                 }
>         swap(cells_, new_cells);
>         swap(cellinfo_, new_cellinfo);
> 
>         ColInfo inf;
>         inf.skip_  = defaultColSpace(newcol);
>         inf.align_ = defaultColAlign(newcol);
>         colinfo_.insert(colinfo_.begin() + newcol, inf);
> }
> 
> This function is apparently supposed to insert a new column at position
> newcol. I understand that columns (and rows and cells) start counting
> at 0. What I don't understand it what happens with the indicated (col >
> newcol). What this will do is shift the contents of the current column
> one place to the right, for all columns to the right of the new column.
> *The content of the current column doesn't get shifted* and stays in
> what is supposed to be a new, empty column. It the next one that will
> remain empty, but with old spacing/alignment data AFAICS.
> 
> Is this intentional or a bug?


I propose to commit the attached, as I believe it is correct. 

Will this change break anything else? What should I look for?
Superficially it seems to be OK.

- Martin
Index: InsetMathGrid.cpp
===================================================================
--- InsetMathGrid.cpp	(revision 20732)
+++ InsetMathGrid.cpp	(working copy)
@@ -743,9 +743,9 @@
 
 	for (row_type row = 0; row < nr; ++row)
 		for (col_type col = 0; col < nc; ++col) {
-			new_cells[row * (nc + 1) + col + (col > newcol)]
+			new_cells[row * (nc + 1) + col + (col >= newcol)]
 				= cells_[row * nc + col];
-			new_cellinfo[row * (nc + 1) + col + (col > newcol)]
+			new_cellinfo[row * (nc + 1) + col + (col >= newcol)]
 				= cellinfo_[row * nc + col];
 		}
 	swap(cells_, new_cells);

Reply via email to