Fix returning duplicates from Get{Row,Col}Selection()
The "unique" rows/columns arrays used in the implementation of these functions were not unique at all, as we happily added duplicates of the existing items into them. Fix this by checking that a row/column is not already present before adding it. Add a (previously failing) unit test checking that this works correctly with overlapping selected blocks.
This commit is contained in:
@@ -901,6 +901,12 @@ TEST_CASE_METHOD(GridTestCase, "Grid::SelectionMode", "[grid]")
|
||||
CHECK(selectedRows.Count() == 1);
|
||||
CHECK(selectedRows[0] == 3);
|
||||
|
||||
// Check that overlapping selection blocks are handled correctly.
|
||||
m_grid->ClearSelection();
|
||||
m_grid->SelectBlock(0, 0, 4, 1);
|
||||
m_grid->SelectBlock(2, 0, 6, 1, true /* add to selection */);
|
||||
CHECK( m_grid->GetSelectedRows().size() == 7 );
|
||||
|
||||
CHECK(m_grid->GetSelectionMode() == wxGrid::wxGridSelectRows);
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user