From cc283fd5dc69277d968c52f8537d050c1f49fce1 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sun, 13 Mar 2022 14:27:46 +1100 Subject: [PATCH 1/2] allow option to enable/disable the use of index in path search --- .../Languages/en.xaml | 2 ++ .../Flow.Launcher.Plugin.Explorer/Settings.cs | 2 +- .../ViewModels/SettingsViewModel.cs | 11 ++++++++++ .../Views/ExplorerSettings.xaml | 21 ++++++++++++------- .../Views/ExplorerSettings.xaml.cs | 2 ++ 5 files changed, 30 insertions(+), 8 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml index e23bd77bd..053cbff2c 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml @@ -23,6 +23,8 @@ Customise Action Keywords Quick Access Links Index Search Excluded Paths + Use Index Search For Path Search + 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 Indexing Options Search: Path Search: diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs index 351091dfe..90b85d187 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs @@ -14,7 +14,7 @@ namespace Flow.Launcher.Plugin.Explorer // as at v1.7.0 this is to maintain backwards compatibility, need to be removed afterwards. public List QuickFolderAccessLinks { get; set; } = new List(); - public bool UseWindowsIndexForDirectorySearch { get; set; } = true; + public bool UseWindowsIndexForDirectorySearch { get; set; } = false; public List IndexSearchExcludedSubdirectoryPaths { get; set; } = new List(); diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs index 77ec5457b..9167691b4 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs @@ -52,5 +52,16 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels } internal bool IsNewActionKeywordGlobal(string newActionKeyword) => newActionKeyword == Query.GlobalPluginWildcardSign; + + public bool UseWindowsIndexForDirectorySearch { + get + { + return Settings.UseWindowsIndexForDirectorySearch; + } + set + { + Settings.UseWindowsIndexForDirectorySearch = value; + } + } } } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml index bbaacc18c..8f82c0a16 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml @@ -4,7 +4,6 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:viewModels="clr-namespace:Flow.Launcher.Plugin.Explorer.ViewModels" xmlns:views="clr-namespace:Flow.Launcher.Plugin.Explorer.Views" d:DesignHeight="450" d:DesignWidth="800" @@ -91,12 +90,20 @@ Margin="0,10,0,0" Expanded="expExcludedPaths_Click" Header="{DynamicResource plugin_explorer_indexsearchexcludedpaths_header}"> - + + + + diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs index 6f0bc49ee..37b6a95d8 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs @@ -29,6 +29,8 @@ namespace Flow.Launcher.Plugin.Explorer.Views this.viewModel = viewModel; + DataContext = viewModel; + lbxAccessLinks.ItemsSource = this.viewModel.Settings.QuickAccessLinks; lbxExcludedPaths.ItemsSource = this.viewModel.Settings.IndexSearchExcludedSubdirectoryPaths; From a276022fbf91756d1ded9bf7687c0582c937c507 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sun, 13 Mar 2022 16:50:41 +1100 Subject: [PATCH 2/2] fix error logging message --- .../Languages/en.xaml | 1 + .../DirectoryInfo/DirectoryInfoSearch.cs | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml index 053cbff2c..e703d8545 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml @@ -15,6 +15,7 @@ To fix this, start the Windows Search service. Select here to remove this warning 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 Explorer Alternative + Error occurred during search: {0} Delete diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs index 14c90d57f..93b68675f 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs @@ -1,4 +1,4 @@ -using Flow.Launcher.Infrastructure.Logger; +using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Plugin.SharedCommands; using System; using System.Collections.Generic; @@ -58,8 +58,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo { var directoryInfo = new System.IO.DirectoryInfo(path); - foreach (var fileSystemInfo in directoryInfo.EnumerateFileSystemInfos(searchCriteria, enumerationOption) - ) + foreach (var fileSystemInfo in directoryInfo.EnumerateFileSystemInfos(searchCriteria, enumerationOption)) { if (fileSystemInfo is System.IO.DirectoryInfo) { @@ -76,8 +75,17 @@ namespace Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo } catch (Exception e) { - Log.Exception("Flow.Plugin.Explorer.", nameof(DirectoryInfoSearch), e); - results.Add(new Result {Title = e.Message, Score = 501}); + Log.Exception(nameof(DirectoryInfoSearch), "Error occured while searching path", e); + + results.Add( + new Result + { + Title = string.Format(SearchManager.Context.API.GetTranslation( + "plugin_explorer_directoryinfosearch_error"), + e.Message), + Score = 501, + IcoPath = Constants.ExplorerIconImagePath + }); return results; }