Merge pull request #2874 from Ishmaeel/ishmaeel_2873

Pass MaxResult setting to EverythingApi
This commit is contained in:
Jeremy Wu 2024-08-12 22:34:37 +10:00 committed by GitHub
commit 7d55d972d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 48 additions and 3 deletions

View file

@ -66,6 +66,8 @@
<system:String x:Key="plugin_explorer_Open_Window_Index_Option">Open Windows Index Option</system:String>
<system:String x:Key="plugin_explorer_Excluded_File_Types">Excluded File Types (comma seperated)</system:String>
<system:String x:Key="plugin_explorer_Excluded_File_Types_Tooltip">For example: exe,jpg,png</system:String>
<system:String x:Key="plugin_explorer_Maximum_Results">Maximum results</system:String>
<system:String x:Key="plugin_explorer_Maximum_Results_Tooltip">The maximum number of results requested from active search engine</system:String>
<!-- Plugin Infos -->
<system:String x:Key="plugin_explorer_plugin_name">Explorer</system:String>

View file

@ -64,7 +64,11 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything
if (token.IsCancellationRequested)
yield break;
var option = new EverythingSearchOption(search, Settings.SortOption, IsFullPathSearch: Settings.EverythingSearchFullPath, IsRunCounterEnabled: Settings.EverythingEnableRunCount);
var option = new EverythingSearchOption(search,
Settings.SortOption,
MaxCount: Settings.MaxResult,
IsFullPathSearch: Settings.EverythingSearchFullPath,
IsRunCounterEnabled: Settings.EverythingEnableRunCount);
await foreach (var result in EverythingApi.SearchAsync(option, token))
yield return result;
@ -96,6 +100,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything
Settings.SortOption,
IsContentSearch: true,
ContentSearchKeyword: contentSearch,
MaxCount: Settings.MaxResult,
IsFullPathSearch: Settings.EverythingSearchFullPath,
IsRunCounterEnabled: Settings.EverythingEnableRunCount);
@ -116,6 +121,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything
Settings.SortOption,
ParentPath: path,
IsRecursive: recursive,
MaxCount: Settings.MaxResult,
IsFullPathSearch: Settings.EverythingSearchFullPath,
IsRunCounterEnabled: Settings.EverythingEnableRunCount);

View file

@ -525,6 +525,19 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels
}
}
public int MaxResultLowerLimit => 100;
public int MaxResultUpperLimit => 100000;
public int MaxResult
{
get => Settings.MaxResult;
set
{
Settings.MaxResult = Math.Clamp(value, MaxResultLowerLimit, MaxResultUpperLimit);
OnPropertyChanged();
}
}
#region Everything FastSortWarning

View file

@ -282,6 +282,7 @@
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock
Grid.Row="0"
@ -348,6 +349,24 @@
Margin="0,9,0,6"
ToolTip="{DynamicResource plugin_explorer_Excluded_File_Types_Tooltip}"
Text="{Binding ExcludedFileTypes}" />
<TextBlock
Grid.Row="4"
Grid.Column="0"
Margin="0 15 20 0"
VerticalAlignment="Center"
Text="{DynamicResource plugin_explorer_Maximum_Results}"
TextBlock.Foreground="{DynamicResource Color05B}" />
<TextBox
Grid.Row="4"
Grid.Column="1"
MinWidth="350"
Margin="0,9,0,6"
HorizontalAlignment="Left"
VerticalAlignment="Center"
PreviewTextInput="AllowOnlyNumericInput"
MaxLength="6"
Text="{Binding MaxResult}"
ToolTip="{DynamicResource plugin_explorer_Maximum_Results_Tooltip}"/>
</Grid>
</StackPanel>
<StackPanel Orientation="Horizontal">

View file

@ -1,4 +1,4 @@
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
using Flow.Launcher.Plugin.Explorer.ViewModels;
using System.Collections.Generic;
using System.ComponentModel;
@ -40,7 +40,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views
}
private void AccessLinkDragDrop(string containerName, DragEventArgs e)
{
var files = (string[])e.Data.GetData(DataFormats.FileDrop);
@ -94,5 +94,10 @@ namespace Flow.Launcher.Plugin.Explorer.Views
{
AccessLinkDragDrop("IndexSearchExcludedPath", e);
}
private void AllowOnlyNumericInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
{
e.Handled = e.Text.ToCharArray().Any(c => !char.IsDigit(c));
}
}
}