Skip to content

Commit 7d55d97

Browse files
authored
Merge pull request #2874 from Ishmaeel/ishmaeel_2873
Pass MaxResult setting to EverythingApi
2 parents 59ed2b1 + 672854b commit 7d55d97

File tree

5 files changed

+48
-3
lines changed

5 files changed

+48
-3
lines changed

Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml

+2
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@
6666
<system:String x:Key="plugin_explorer_Open_Window_Index_Option">Open Windows Index Option</system:String>
6767
<system:String x:Key="plugin_explorer_Excluded_File_Types">Excluded File Types (comma seperated)</system:String>
6868
<system:String x:Key="plugin_explorer_Excluded_File_Types_Tooltip">For example: exe,jpg,png</system:String>
69+
<system:String x:Key="plugin_explorer_Maximum_Results">Maximum results</system:String>
70+
<system:String x:Key="plugin_explorer_Maximum_Results_Tooltip">The maximum number of results requested from active search engine</system:String>
6971

7072
<!-- Plugin Infos -->
7173
<system:String x:Key="plugin_explorer_plugin_name">Explorer</system:String>

Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingSearchManager.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ public async IAsyncEnumerable<SearchResult> SearchAsync(string search, [Enumerat
6464
if (token.IsCancellationRequested)
6565
yield break;
6666

67-
var option = new EverythingSearchOption(search, Settings.SortOption, IsFullPathSearch: Settings.EverythingSearchFullPath, IsRunCounterEnabled: Settings.EverythingEnableRunCount);
67+
var option = new EverythingSearchOption(search,
68+
Settings.SortOption,
69+
MaxCount: Settings.MaxResult,
70+
IsFullPathSearch: Settings.EverythingSearchFullPath,
71+
IsRunCounterEnabled: Settings.EverythingEnableRunCount);
6872

6973
await foreach (var result in EverythingApi.SearchAsync(option, token))
7074
yield return result;
@@ -96,6 +100,7 @@ public async IAsyncEnumerable<SearchResult> ContentSearchAsync(string plainSearc
96100
Settings.SortOption,
97101
IsContentSearch: true,
98102
ContentSearchKeyword: contentSearch,
103+
MaxCount: Settings.MaxResult,
99104
IsFullPathSearch: Settings.EverythingSearchFullPath,
100105
IsRunCounterEnabled: Settings.EverythingEnableRunCount);
101106

@@ -116,6 +121,7 @@ public async IAsyncEnumerable<SearchResult> EnumerateAsync(string path, string s
116121
Settings.SortOption,
117122
ParentPath: path,
118123
IsRecursive: recursive,
124+
MaxCount: Settings.MaxResult,
119125
IsFullPathSearch: Settings.EverythingSearchFullPath,
120126
IsRunCounterEnabled: Settings.EverythingEnableRunCount);
121127

Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs

+13
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,19 @@ public string ExcludedFileTypes
525525
}
526526
}
527527

528+
public int MaxResultLowerLimit => 100;
529+
public int MaxResultUpperLimit => 100000;
530+
531+
public int MaxResult
532+
{
533+
get => Settings.MaxResult;
534+
set
535+
{
536+
Settings.MaxResult = Math.Clamp(value, MaxResultLowerLimit, MaxResultUpperLimit);
537+
OnPropertyChanged();
538+
}
539+
}
540+
528541

529542
#region Everything FastSortWarning
530543

Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml

+19
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@
282282
<RowDefinition />
283283
<RowDefinition />
284284
<RowDefinition />
285+
<RowDefinition />
285286
</Grid.RowDefinitions>
286287
<TextBlock
287288
Grid.Row="0"
@@ -348,6 +349,24 @@
348349
Margin="0,9,0,6"
349350
ToolTip="{DynamicResource plugin_explorer_Excluded_File_Types_Tooltip}"
350351
Text="{Binding ExcludedFileTypes}" />
352+
<TextBlock
353+
Grid.Row="4"
354+
Grid.Column="0"
355+
Margin="0 15 20 0"
356+
VerticalAlignment="Center"
357+
Text="{DynamicResource plugin_explorer_Maximum_Results}"
358+
TextBlock.Foreground="{DynamicResource Color05B}" />
359+
<TextBox
360+
Grid.Row="4"
361+
Grid.Column="1"
362+
MinWidth="350"
363+
Margin="0,9,0,6"
364+
HorizontalAlignment="Left"
365+
VerticalAlignment="Center"
366+
PreviewTextInput="AllowOnlyNumericInput"
367+
MaxLength="6"
368+
Text="{Binding MaxResult}"
369+
ToolTip="{DynamicResource plugin_explorer_Maximum_Results_Tooltip}"/>
351370
</Grid>
352371
</StackPanel>
353372
<StackPanel Orientation="Horizontal">

Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
1+
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
22
using Flow.Launcher.Plugin.Explorer.ViewModels;
33
using System.Collections.Generic;
44
using System.ComponentModel;
@@ -40,7 +40,7 @@ public ExplorerSettings(SettingsViewModel viewModel)
4040
}
4141

4242

43-
43+
4444
private void AccessLinkDragDrop(string containerName, DragEventArgs e)
4545
{
4646
var files = (string[])e.Data.GetData(DataFormats.FileDrop);
@@ -94,5 +94,10 @@ private void LbxExcludedPaths_OnDrop(object sender, DragEventArgs e)
9494
{
9595
AccessLinkDragDrop("IndexSearchExcludedPath", e);
9696
}
97+
98+
private void AllowOnlyNumericInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
99+
{
100+
e.Handled = e.Text.ToCharArray().Any(c => !char.IsDigit(c));
101+
}
97102
}
98103
}

0 commit comments

Comments
 (0)