Merge pull request #348 from Flow-Launcher/fix_duplicate_entry_quickaccess

Remove duplicate entry
This commit is contained in:
Hongtao Zhang 2021-02-19 02:28:56 -08:00 committed by GitHub
commit 554bc08a8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 13 deletions

View file

@ -1,16 +1,13 @@
using System;
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Plugin;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Plugin;
namespace Flow.Launcher.ViewModel
{

View file

@ -22,9 +22,24 @@ namespace Flow.Launcher.Plugin.Explorer.Search
this.settings = settings;
}
private class PathEqualityComparator : IEqualityComparer<Result>
{
private static PathEqualityComparator instance;
public static PathEqualityComparator Instance => instance ??= new PathEqualityComparator();
public bool Equals(Result x, Result y)
{
return x.SubTitle == y.SubTitle;
}
public int GetHashCode(Result obj)
{
return obj.SubTitle.GetHashCode();
}
}
internal async Task<List<Result>> SearchAsync(Query query, CancellationToken token)
{
var results = new List<Result>();
var results = new HashSet<Result>(PathEqualityComparator.Instance);
var querySearch = query.Search;
@ -38,7 +53,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
var quickaccessLinks = QuickAccess.AccessLinkListMatched(query, settings.QuickAccessLinks);
if (quickaccessLinks.Count > 0)
results.AddRange(quickaccessLinks);
results.UnionWith(quickaccessLinks);
var isEnvironmentVariable = EnvironmentVariables.IsEnvironmentVariableSearch(querySearch);
@ -50,9 +65,9 @@ namespace Flow.Launcher.Plugin.Explorer.Search
if (!querySearch.IsLocationPathString() && !isEnvironmentVariablePath)
{
results.AddRange(await WindowsIndexFilesAndFoldersSearchAsync(query, querySearch, token).ConfigureAwait(false));
results.UnionWith(await WindowsIndexFilesAndFoldersSearchAsync(query, querySearch, token).ConfigureAwait(false));
return results;
return results.ToList();
}
var locationPath = querySearch;
@ -62,7 +77,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
// Check that actual location exists, otherwise directory search will throw directory not found exception
if (!FilesFolders.LocationExists(FilesFolders.ReturnPreviousDirectoryIfIncompleteString(locationPath)))
return results;
return results.ToList();
var useIndexSearch = UseWindowsIndexForDirectorySearch(locationPath);
@ -79,9 +94,9 @@ namespace Flow.Launcher.Plugin.Explorer.Search
token.ThrowIfCancellationRequested();
results.AddRange(directoryResult);
results.UnionWith(directoryResult);
return results;
return results.ToList();
}
private async Task<List<Result>> WindowsIndexFileContentSearchAsync(Query query, string querySearchString, CancellationToken token)

View file

@ -7,7 +7,7 @@
"Name": "Explorer",
"Description": "Search and manage files and folders. Explorer utilises Windows Index Search",
"Author": "Jeremy Wu",
"Version": "1.7.0",
"Version": "1.7.1",
"Language": "csharp",
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
"ExecuteFileName": "Flow.Launcher.Plugin.Explorer.dll",