Skip to content

Commit 377c7d7

Browse files
authored
Merge pull request #1076 from Flow-Launcher/fix_path_search_with_index
Fix the use of index in path search
2 parents 51a8916 + a276022 commit 377c7d7

File tree

6 files changed

+44
-13
lines changed

6 files changed

+44
-13
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<system:String x:Key="plugin_explorer_windowsSearchServiceFix">To fix this, start the Windows Search service. Select here to remove this warning</system:String>
1616
<system:String x:Key="plugin_explorer_alternative">The warning message has been switched off. As an alternative for searching files and folders, would you like to install Everything plugin?{0}{0}Select 'Yes' to install Everything plugin, or 'No' to return</system:String>
1717
<system:String x:Key="plugin_explorer_alternative_title">Explorer Alternative</system:String>
18+
<system:String x:Key="plugin_explorer_directoryinfosearch_error">Error occurred during search: {0}</system:String>
1819

1920
<!--Controls-->
2021
<system:String x:Key="plugin_explorer_delete">Delete</system:String>
@@ -23,6 +24,8 @@
2324
<system:String x:Key="plugin_explorer_manageactionkeywords_header">Customise Action Keywords</system:String>
2425
<system:String x:Key="plugin_explorer_quickaccesslinks_header">Quick Access Links</system:String>
2526
<system:String x:Key="plugin_explorer_indexsearchexcludedpaths_header">Index Search Excluded Paths</system:String>
27+
<system:String x:Key="plugin_explorer_usewindowsindexfordirectorysearch">Use Index Search For Path Search</system:String>
28+
<system:String x:Key="plugin_explorer_usewindowsindexfordirectorysearch_tooltip">Turning this on will return indexed directories/files faster, but if a directory/file is not indexed it will not show up. If a directory/file has been added to Index Search Excluded Path then it will still show up even if this option is on</system:String>
2629
<system:String x:Key="plugin_explorer_manageindexoptions">Indexing Options</system:String>
2730
<system:String x:Key="plugin_explorer_actionkeywordview_search">Search:</system:String>
2831
<system:String x:Key="plugin_explorer_actionkeywordview_pathsearch">Path Search:</system:String>

Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Flow.Launcher.Infrastructure.Logger;
1+
using Flow.Launcher.Infrastructure.Logger;
22
using Flow.Launcher.Plugin.SharedCommands;
33
using System;
44
using System.Collections.Generic;
@@ -58,8 +58,7 @@ private static List<Result> DirectorySearch(EnumerationOptions enumerationOption
5858
{
5959
var directoryInfo = new System.IO.DirectoryInfo(path);
6060

61-
foreach (var fileSystemInfo in directoryInfo.EnumerateFileSystemInfos(searchCriteria, enumerationOption)
62-
)
61+
foreach (var fileSystemInfo in directoryInfo.EnumerateFileSystemInfos(searchCriteria, enumerationOption))
6362
{
6463
if (fileSystemInfo is System.IO.DirectoryInfo)
6564
{
@@ -76,8 +75,17 @@ private static List<Result> DirectorySearch(EnumerationOptions enumerationOption
7675
}
7776
catch (Exception e)
7877
{
79-
Log.Exception("Flow.Plugin.Explorer.", nameof(DirectoryInfoSearch), e);
80-
results.Add(new Result {Title = e.Message, Score = 501});
78+
Log.Exception(nameof(DirectoryInfoSearch), "Error occured while searching path", e);
79+
80+
results.Add(
81+
new Result
82+
{
83+
Title = string.Format(SearchManager.Context.API.GetTranslation(
84+
"plugin_explorer_directoryinfosearch_error"),
85+
e.Message),
86+
Score = 501,
87+
IcoPath = Constants.ExplorerIconImagePath
88+
});
8189

8290
return results;
8391
}

Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class Settings
1414
// as at v1.7.0 this is to maintain backwards compatibility, need to be removed afterwards.
1515
public List<AccessLink> QuickFolderAccessLinks { get; set; } = new List<AccessLink>();
1616

17-
public bool UseWindowsIndexForDirectorySearch { get; set; } = true;
17+
public bool UseWindowsIndexForDirectorySearch { get; set; } = false;
1818

1919
public List<AccessLink> IndexSearchExcludedSubdirectoryPaths { get; set; } = new List<AccessLink>();
2020

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,16 @@ internal bool IsActionKeywordAlreadyAssigned(string newActionKeyword)
5252
}
5353

5454
internal bool IsNewActionKeywordGlobal(string newActionKeyword) => newActionKeyword == Query.GlobalPluginWildcardSign;
55+
56+
public bool UseWindowsIndexForDirectorySearch {
57+
get
58+
{
59+
return Settings.UseWindowsIndexForDirectorySearch;
60+
}
61+
set
62+
{
63+
Settings.UseWindowsIndexForDirectorySearch = value;
64+
}
65+
}
5566
}
5667
}

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

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7-
xmlns:viewModels="clr-namespace:Flow.Launcher.Plugin.Explorer.ViewModels"
87
xmlns:views="clr-namespace:Flow.Launcher.Plugin.Explorer.Views"
98
d:DesignHeight="450"
109
d:DesignWidth="800"
@@ -92,12 +91,20 @@
9291
Collapsed="expExcludedPaths_Collapsed"
9392
Expanded="expExcludedPaths_Click"
9493
Header="{DynamicResource plugin_explorer_indexsearchexcludedpaths_header}">
95-
<ListView
96-
x:Name="lbxExcludedPaths"
97-
AllowDrop="True"
98-
DragEnter="lbxAccessLinks_DragEnter"
99-
Drop="lbxAccessLinks_Drop"
100-
ItemTemplate="{StaticResource ListViewTemplateExcludedPaths}" />
94+
<StackPanel>
95+
<CheckBox
96+
Name="UseWindowsIndexForDirectorySearch"
97+
Margin="12,10,0,0"
98+
Content="{DynamicResource plugin_explorer_usewindowsindexfordirectorysearch}"
99+
IsChecked="{Binding UseWindowsIndexForDirectorySearch}"
100+
ToolTip="{DynamicResource plugin_explorer_usewindowsindexfordirectorysearch_tooltip}" />
101+
<ListView
102+
x:Name="lbxExcludedPaths"
103+
AllowDrop="True"
104+
DragEnter="lbxAccessLinks_DragEnter"
105+
Drop="lbxAccessLinks_Drop"
106+
ItemTemplate="{StaticResource ListViewTemplateExcludedPaths}" />
107+
</StackPanel>
101108
</Expander>
102109
</StackPanel>
103110
</ScrollViewer>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public ExplorerSettings(SettingsViewModel viewModel)
2929

3030
this.viewModel = viewModel;
3131

32+
DataContext = viewModel;
33+
3234
lbxAccessLinks.ItemsSource = this.viewModel.Settings.QuickAccessLinks;
3335

3436
lbxExcludedPaths.ItemsSource = this.viewModel.Settings.IndexSearchExcludedSubdirectoryPaths;

0 commit comments

Comments
 (0)