@@ -22,9 +22,24 @@ public SearchManager(Settings settings, PluginInitContext context)
2222 this . settings = settings ;
2323 }
2424
25+ private class PathEqualityComparator : IEqualityComparer < Result >
26+ {
27+ private static PathEqualityComparator instance ;
28+ public static PathEqualityComparator Instance => instance ??= new PathEqualityComparator ( ) ;
29+ public bool Equals ( Result x , Result y )
30+ {
31+ return x . SubTitle == y . SubTitle ;
32+ }
33+
34+ public int GetHashCode ( Result obj )
35+ {
36+ return obj . SubTitle . GetHashCode ( ) ;
37+ }
38+ }
39+
2540 internal async Task < List < Result > > SearchAsync ( Query query , CancellationToken token )
2641 {
27- var results = new List < Result > ( ) ;
42+ var results = new HashSet < Result > ( PathEqualityComparator . Instance ) ;
2843
2944 var querySearch = query . Search ;
3045
@@ -38,7 +53,7 @@ internal async Task<List<Result>> SearchAsync(Query query, CancellationToken tok
3853 var quickaccessLinks = QuickAccess . AccessLinkListMatched ( query , settings . QuickAccessLinks ) ;
3954
4055 if ( quickaccessLinks . Count > 0 )
41- results . AddRange ( quickaccessLinks ) ;
56+ results . UnionWith ( quickaccessLinks ) ;
4257
4358 var isEnvironmentVariable = EnvironmentVariables . IsEnvironmentVariableSearch ( querySearch ) ;
4459
@@ -50,9 +65,9 @@ internal async Task<List<Result>> SearchAsync(Query query, CancellationToken tok
5065
5166 if ( ! querySearch . IsLocationPathString ( ) && ! isEnvironmentVariablePath )
5267 {
53- results . AddRange ( await WindowsIndexFilesAndFoldersSearchAsync ( query , querySearch , token ) . ConfigureAwait ( false ) ) ;
68+ results . UnionWith ( await WindowsIndexFilesAndFoldersSearchAsync ( query , querySearch , token ) . ConfigureAwait ( false ) ) ;
5469
55- return results ;
70+ return results . ToList ( ) ;
5671 }
5772
5873 var locationPath = querySearch ;
@@ -62,7 +77,7 @@ internal async Task<List<Result>> SearchAsync(Query query, CancellationToken tok
6277
6378 // Check that actual location exists, otherwise directory search will throw directory not found exception
6479 if ( ! FilesFolders . LocationExists ( FilesFolders . ReturnPreviousDirectoryIfIncompleteString ( locationPath ) ) )
65- return results ;
80+ return results . ToList ( ) ;
6681
6782 var useIndexSearch = UseWindowsIndexForDirectorySearch ( locationPath ) ;
6883
@@ -79,9 +94,9 @@ internal async Task<List<Result>> SearchAsync(Query query, CancellationToken tok
7994
8095 token . ThrowIfCancellationRequested ( ) ;
8196
82- results . AddRange ( directoryResult ) ;
97+ results . UnionWith ( directoryResult ) ;
8398
84- return results ;
99+ return results . ToList ( ) ;
85100 }
86101
87102 private async Task < List < Result > > WindowsIndexFileContentSearchAsync ( Query query , string querySearchString , CancellationToken token )
0 commit comments