Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions Flow.Launcher/ViewModel/ResultsViewModel.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down
29 changes: 22 additions & 7 deletions Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,24 @@ public SearchManager(Settings settings, PluginInitContext context)
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;

Expand All @@ -38,7 +53,7 @@ internal async Task<List<Result>> SearchAsync(Query query, CancellationToken tok
var quickaccessLinks = QuickAccess.AccessLinkListMatched(query, settings.QuickAccessLinks);

if (quickaccessLinks.Count > 0)
results.AddRange(quickaccessLinks);
results.UnionWith(quickaccessLinks);

var isEnvironmentVariable = EnvironmentVariables.IsEnvironmentVariableSearch(querySearch);

Expand All @@ -50,9 +65,9 @@ internal async Task<List<Result>> SearchAsync(Query query, CancellationToken tok

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;
Expand All @@ -62,7 +77,7 @@ internal async Task<List<Result>> SearchAsync(Query query, CancellationToken tok

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

Expand All @@ -79,9 +94,9 @@ internal async Task<List<Result>> SearchAsync(Query query, CancellationToken tok

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)
Expand Down
2 changes: 1 addition & 1 deletion Plugins/Flow.Launcher.Plugin.Explorer/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down