Skip to content

Conversation

@jjw24
Copy link
Member

@jjw24 jjw24 commented Feb 16, 2021

When result exists from both Quick Access and file search, use unionwith and custom comparer instead of append, so this will return distinct results of duplicates

@jjw24 jjw24 added the bug Something isn't working label Feb 16, 2021
@jjw24 jjw24 self-assigned this Feb 16, 2021
@jjw24 jjw24 enabled auto-merge February 16, 2021 21:52
@jjw24 jjw24 marked this pull request as draft February 16, 2021 21:58
auto-merge was automatically disabled February 16, 2021 21:58

Pull request was converted to draft

@taooceros
Copy link
Member

Union won't work like this. This Union will create a IEnumerable that has been unioned, but not put the results back to the list. It would be better to use HashSet if you want to do the same job.
You may need to use HashSet and Union.

@taooceros
Copy link
Member

Or actually using an distinct will work, but will create another hashset to do the same job, so it would be better to simply do that with a hashset.

@jjw24
Copy link
Member Author

jjw24 commented Feb 17, 2021

I actually think we should maybe do this so all plugin results will benefit, so plugins dont have to worry about dup results. What do you think

@taooceros
Copy link
Member

taooceros commented Feb 17, 2021

I actually think we should maybe do this so all plugin results will benefit, so plugins dont have to worry about dup results. What do you think

Agree with you, it is easy to do that. Just adding a distinct to the NewResults method should work

Add distinct to NewResults to try avoiding duplicate result
@taooceros
Copy link
Member

@jjw24 done, please take a look

@taooceros taooceros changed the title Remove duplicate entry with quick access results Remove duplicate entry Feb 17, 2021

if (quickaccessLinks.Count > 0)
results.AddRange(quickaccessLinks);
results.Union(quickaccessLinks);
Copy link
Member Author

Choose a reason for hiding this comment

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

Distinct hasnt solved it yet, this change has been reverted. We probably need to write our own comparer

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I think you are right. By seeing the code of the equality comparator of Result class, it requires more than just title match. Maybe we still need to do that separately for plugins instead of distinct overall because we seldom will add two results that will be identical (they need to be equal at title, score, and highlight data) to the result list.

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah i agree. Perhaps we can create and add it to IPublicAPI so plugins can utilise the return distinct results themselves

Copy link
Member

Choose a reason for hiding this comment

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

Well I don't think it should be included in IPublicAPI, because how they should filter the result should be decided by them. If we allow Equaltycomparater for that, I don't see the different between putting that in IPublicAPI and doing that by distinct or hashset.

Copy link
Member

Choose a reason for hiding this comment

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

Let me add a customized add a customized equality comparator to do this job by comparing the subtitle (it is supposed to be the path) to remove duplicate for this one.

@taooceros
Copy link
Member

Done, please take a look @jjw24
I haven't tested it, but it supposed to work

@jjw24
Copy link
Member Author

jjw24 commented Feb 18, 2021

should we revert commit 4a3ad08?

@taooceros
Copy link
Member

should we revert commit 4a3ad08?

Yeah we can do that. Seems that a simple distinct doesn't work well.

@jjw24 jjw24 marked this pull request as ready for review February 19, 2021 10:05
@jjw24
Copy link
Member Author

jjw24 commented Feb 19, 2021

@taooceros good to roll?

@taooceros taooceros merged commit 554bc08 into dev Feb 19, 2021
@taooceros taooceros deleted the fix_duplicate_entry_quickaccess branch February 19, 2021 10:28
This was referenced Feb 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants