Merge pull request #1899 from Flow-Launcher/everything_full_path_option

add option for everything search in full path (default true)
This commit is contained in:
Jeremy Wu 2023-02-21 08:24:05 +11:00 committed by GitHub
commit 3b05ee2582
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 4 deletions

View file

@ -127,6 +127,8 @@
<system:String x:Key="flowlauncher_plugin_everything_sort_by_descending">&#x2193;</system:String>
<system:String x:Key="flowlauncher_plugin_everything_nonfastsort_warning">Warning: This is not a Fast Sort option, searches may be slow</system:String>
<system:String x:Key="flowlauncher_plugin_everything_search_fullpath">Search Full Path</system:String>
<system:String x:Key="flowlauncher_plugin_everything_click_to_launch_or_install">Click to launch or install Everything</system:String>
<system:String x:Key="flowlauncher_plugin_everything_installing_title">Everything Installation</system:String>
<system:String x:Key="flowlauncher_plugin_everything_installing_subtitle">Installing Everything service. Please wait...</system:String>

View file

@ -42,29 +42,38 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything
private async ValueTask<bool> ClickToInstallEverythingAsync(ActionContext _)
{
var installedPath = await EverythingDownloadHelper.PromptDownloadIfNotInstallAsync(Settings.EverythingInstalledPath, Main.Context.API);
if (installedPath == null)
{
Main.Context.API.ShowMsgError("Unable to find Everything.exe");
return false;
}
Settings.EverythingInstalledPath = installedPath;
Process.Start(installedPath, "-startup");
return true;
}
public async IAsyncEnumerable<SearchResult> SearchAsync(string search, [EnumeratorCancellation] CancellationToken token)
{
await ThrowIfEverythingNotAvailableAsync(token);
if (token.IsCancellationRequested)
yield break;
var option = new EverythingSearchOption(search, Settings.SortOption);
var option = new EverythingSearchOption(search, Settings.SortOption, IsFullPathSearch: Settings.EverythingSearchFullPath);
await foreach (var result in EverythingApi.SearchAsync(option, token))
yield return result;
}
public async IAsyncEnumerable<SearchResult> ContentSearchAsync(string plainSearch,
string contentSearch, [EnumeratorCancellation] CancellationToken token)
string contentSearch,
[EnumeratorCancellation] CancellationToken token)
{
await ThrowIfEverythingNotAvailableAsync(token);
if (!Settings.EnableEverythingContentSearch)
{
throw new EngineNotAvailableException(Enum.GetName(Settings.IndexSearchEngineOption.Everything)!,
@ -74,16 +83,19 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything
_ =>
{
Settings.EnableEverythingContentSearch = true;
return ValueTask.FromResult(true);
});
}
if (token.IsCancellationRequested)
yield break;
var option = new EverythingSearchOption(plainSearch,
Settings.SortOption,
true,
contentSearch);
contentSearch,
IsFullPathSearch: Settings.EverythingSearchFullPath);
await foreach (var result in EverythingApi.SearchAsync(option, token))
{
@ -93,13 +105,15 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything
public async IAsyncEnumerable<SearchResult> EnumerateAsync(string path, string search, bool recursive, [EnumeratorCancellation] CancellationToken token)
{
await ThrowIfEverythingNotAvailableAsync(token);
if (token.IsCancellationRequested)
yield break;
var option = new EverythingSearchOption(search,
Settings.SortOption,
ParentPath: path,
IsRecursive: recursive);
IsRecursive: recursive,
IsFullPathSearch: Settings.EverythingSearchFullPath);
await foreach (var result in EverythingApi.SearchAsync(option, token))
{

View file

@ -137,6 +137,8 @@ namespace Flow.Launcher.Plugin.Explorer
PathEnumerationEngine == PathEnumerationEngineOption.Everything ||
ContentSearchEngine == ContentIndexSearchEngineOption.Everything;
public bool EverythingSearchFullPath { get; set; } = false;
#endregion
internal enum ActionKeyword

View file

@ -348,6 +348,15 @@
Header="{DynamicResource plugin_explorer_everything_setting_header}"
Style="{DynamicResource ExplorerTabItem}">
<StackPanel Margin="10" Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<TextBlock Margin="10"
VerticalAlignment="Center"
Text="{DynamicResource flowlauncher_plugin_everything_search_fullpath}"/>
<CheckBox Margin="10"
VerticalAlignment="Center"
IsChecked="{Binding Settings.EverythingSearchFullPath}">
</CheckBox>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Grid Margin="20,10,0,10">
<Grid.ColumnDefinitions>