Skip to content

Commit

Permalink
Merge pull request #2874 from Ishmaeel/ishmaeel_2873
Browse files Browse the repository at this point in the history
Pass MaxResult setting to EverythingApi
  • Loading branch information
jjw24 authored Aug 12, 2024
2 parents 59ed2b1 + 672854b commit 7d55d97
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ public async IAsyncEnumerable<SearchResult> SearchAsync(string search, [Enumerat
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;
Expand Down Expand Up @@ -96,6 +100,7 @@ public async IAsyncEnumerable<SearchResult> ContentSearchAsync(string plainSearc
Settings.SortOption,
IsContentSearch: true,
ContentSearchKeyword: contentSearch,
MaxCount: Settings.MaxResult,
IsFullPathSearch: Settings.EverythingSearchFullPath,
IsRunCounterEnabled: Settings.EverythingEnableRunCount);

Expand All @@ -116,6 +121,7 @@ public async IAsyncEnumerable<SearchResult> EnumerateAsync(string path, string s
Settings.SortOption,
ParentPath: path,
IsRecursive: recursive,
MaxCount: Settings.MaxResult,
IsFullPathSearch: Settings.EverythingSearchFullPath,
IsRunCounterEnabled: Settings.EverythingEnableRunCount);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,19 @@ public string ExcludedFileTypes
}
}

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

Expand Down
19 changes: 19 additions & 0 deletions Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock
Grid.Row="0"
Expand Down Expand Up @@ -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">
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -40,7 +40,7 @@ public ExplorerSettings(SettingsViewModel viewModel)
}



private void AccessLinkDragDrop(string containerName, DragEventArgs e)
{
var files = (string[])e.Data.GetData(DataFormats.FileDrop);
Expand Down Expand Up @@ -94,5 +94,10 @@ private void LbxExcludedPaths_OnDrop(object sender, DragEventArgs e)
{
AccessLinkDragDrop("IndexSearchExcludedPath", e);
}

private void AllowOnlyNumericInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
{
e.Handled = e.Text.ToCharArray().Any(c => !char.IsDigit(c));
}
}
}

0 comments on commit 7d55d97

Please sign in to comment.