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:
Vadim Zeitlin
2020-05-26 16:32:05 +02:00
parent f268c02c19
commit 92b6a55fd6
2 changed files with 10 additions and 2 deletions

View File

@@ -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);