Skip to content

Preserve entity selection when filtering/searching#37

Open
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-search-selection-issue
Open

Preserve entity selection when filtering/searching#37
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-search-selection-issue

Conversation

Copy link

Copilot AI commented Dec 10, 2025

Entity search/filter was clearing all checked items, forcing users to re-select entities after each search operation.

Changes

Modified FillListEntities() to preserve checked state across ListView updates:

  • Capture checked entity SchemaNames before clearing items
  • Restore checked state when repopulating with filtered results
private void FillListEntities(List<Entities> items)
{
    // Save checked state before clearing
    var checkedSchemaNames = new HashSet<string>();
    foreach (ListViewItem item in lvEntities.Items)
    {
        if (item.Checked)
            checkedSchemaNames.Add(item.Tag.ToString());
    }

    lvEntities.Items.Clear();
    lvEntities.BeginUpdate();
    foreach (var item in items)
    {
        var listViewItem = new ListViewItem { /* ... */ };
        
        // Restore checked state if previously checked
        if (checkedSchemaNames.Contains(item.SchemaName))
            listViewItem.Checked = true;
            
        lvEntities.Items.Add(listViewItem);
    }
    lvEntities.EndUpdate();
}

Users can now build entity collections incrementally while searching.

Original prompt

This section details on the original issue you should resolve

<issue_title>When searching for entities, selection is cleared</issue_title>
<issue_description>When using the search function for entities, selection is cleared. Instead, I would like selected entities stay selected so that I can get a collection of entities selected quickly. </issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: MscrmTools <10774317+MscrmTools@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix search function to retain selected entities Preserve entity selection when filtering/searching Dec 10, 2025
Copilot AI requested a review from MscrmTools December 10, 2025 09:19
@MscrmTools MscrmTools marked this pull request as ready for review December 11, 2025 08:19
Copy link
Owner

@MscrmTools MscrmTools left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The checkedSchemaNames should be updated to remove the item.SchemaName when an item is unchecked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When searching for entities, selection is cleared

2 participants