From cb7aa5143b5e11bbc480844c48ae4e265cbe88b8 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 31 May 2023 12:25:47 +0100 Subject: [PATCH] Correctly handle hidden columns when pasting into grids. Fixes https://gitlab.com/kicad/code/kicad/-/issues/14844 (cherry picked from commit f9fd37c4ca3e054ab18b2974ee418cfc28682abb) --- common/grid_tricks.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/common/grid_tricks.cpp b/common/grid_tricks.cpp index 0186374751..485df190b9 100644 --- a/common/grid_tricks.cpp +++ b/common/grid_tricks.cpp @@ -726,18 +726,16 @@ void GRID_TRICKS::paste_text( const wxString& cb_text ) wxStringTokenizer cols( rowTxt, COL_SEP, wxTOKEN_RET_EMPTY ); if( !is_selection ) - { end_col = cur_col + cols.CountTokens(); - if( end_col > tbl->GetNumberCols() ) - end_col = tbl->GetNumberCols(); - } - - for( int col = start_col; col < end_col; ++col ) + for( int col = start_col; col < end_col && col < tbl->GetNumberCols(); ++col ) { // Skip hidden columns if( !m_grid->IsColShown( col ) ) + { + end_col++; continue; + } // If number of selected cols is larger than the count of cols on the clipboard, // paste again and again until the end of the selection is reached.