File tree Expand file tree Collapse file tree
SharpConsoleUI/Controls/TableControl Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -747,13 +747,16 @@ void FillSideMargins(int y)
747747 int dataStartY = currentY ;
748748
749749 // Data rows - virtual rendering (only visible rows)
750- int rowCount = RowCount ;
750+ int rowCount = rowSnapshot ? . Count ?? RowCount ;
751751 int startRow = _scrollOffset ;
752752 int endRow = Math . Min ( rowCount , _scrollOffset + GetVisibleRowCount ( ) ) ;
753753
754754 for ( int displayR = startRow ; displayR < endRow && currentY < maxY ; displayR ++ )
755755 {
756756 int dataR = MapDisplayToData ( displayR ) ;
757+ // Guard against snapshot/data race — dataR may be invalid if _rows changed after snapshot
758+ if ( rowSnapshot != null && ( dataR < 0 || dataR >= rowSnapshot . Count ) )
759+ continue ;
757760
758761 // Row separator (between rows, not before first)
759762 if ( displayR > startRow && _showRowSeparators && hasBorder && currentY < maxY )
You can’t perform that action at this time.
0 commit comments