diff --git a/Flow.Launcher.Test/Plugins/ExplorerTest.cs b/Flow.Launcher.Test/Plugins/ExplorerTest.cs index 283e19fdf..fc247d858 100644 --- a/Flow.Launcher.Test/Plugins/ExplorerTest.cs +++ b/Flow.Launcher.Test/Plugins/ExplorerTest.cs @@ -12,7 +12,7 @@ namespace Flow.Launcher.Test.Plugins [TestFixture] public class ExplorerTest { - private List MethodWindowsIndexSearchReturnsZeroResults(string dummyString) + private List MethodWindowsIndexSearchReturnsZeroResults(Query dummyQuery, string dummyString) { return new List(); } @@ -141,8 +141,6 @@ namespace Flow.Launcher.Test.Plugins $"Actual number of results is {results.Count} {Environment.NewLine}"); } - public void GivenWindowsIndexSearch_WhenSearchPatternHotKeyIsSearchAll_ThenQueryWhereRestrictionsShouldUseScopeString() { } - [TestCase(@"c:\\", false)] [TestCase(@"i:\", true)] [TestCase(@"\c:\", false)] @@ -160,5 +158,7 @@ namespace Flow.Launcher.Test.Plugins $"Actual check result is {result} {Environment.NewLine}"); } + + public void GivenWindowsIndexSearch_WhenSearchPatternHotKeyIsSearchAll_ThenQueryWhereRestrictionsShouldUseScopeString() { } } } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs index 3cb2cf842..c06d1db45 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs @@ -53,7 +53,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search querySearch); } - return WindowsIndexFilesAndFoldersSearch(querySearch); + return WindowsIndexFilesAndFoldersSearch(query, querySearch); } private List DirectoryInfoClassSearch(Query query, string querySearch) @@ -64,13 +64,13 @@ namespace Flow.Launcher.Plugin.Explorer.Search } public List TopLevelFolderSearchBehaviour( - Func> windowsIndexSearch, + Func> windowsIndexSearch, Func> directoryInfoClassSearch, Func indexExists, Query query, string querySearchString) { - var results = windowsIndexSearch(querySearchString); + var results = windowsIndexSearch(query, querySearchString); if (results.Count == 0 && !indexExists(querySearchString)) return directoryInfoClassSearch(query, querySearchString); @@ -78,22 +78,24 @@ namespace Flow.Launcher.Plugin.Explorer.Search return results; } - private List WindowsIndexFilesAndFoldersSearch(string querySearchString) + private List WindowsIndexFilesAndFoldersSearch(Query query, string querySearchString) { var queryConstructor = new QueryConstructor(_settings); return searcher.WindowsIndexSearch(querySearchString, queryConstructor.CreateQueryHelper().ConnectionString, - queryConstructor.QueryForAllFilesAndFolders); + queryConstructor.QueryForAllFilesAndFolders, + query); } - private List WindowsIndexTopLevelFolderSearch(string path) + private List WindowsIndexTopLevelFolderSearch(Query query, string path) { var queryConstructor = new QueryConstructor(_settings); return searcher.WindowsIndexSearch(path, queryConstructor.CreateQueryHelper().ConnectionString, - queryConstructor.QueryForTopLevelDirectorySearch); + queryConstructor.QueryForTopLevelDirectorySearch, + query); } private bool WindowsIndexExists(string path) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearcher.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearcher.cs index 6081bf119..b7f172892 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearcher.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearcher.cs @@ -30,7 +30,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex _context = context; } - internal List ExecuteWindowsIndexSearch(string searchString, string connectionString) + internal List ExecuteWindowsIndexSearch(string searchString, string connectionString, Query query) { var results = new List(); @@ -54,7 +54,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex results.Add(CreateResult( dataReaderResults.GetString(0), dataReaderResults.GetString(1), - dataReaderResults.GetString(2))); + dataReaderResults.GetString(2), + query)); } } } @@ -74,30 +75,17 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex return results; } - private Result CreateResult(string filename, string path, string fileType) + private Result CreateResult(string filename, string path, string fileType, Query query) { - return new Result + if (fileType == "Directory") + return ResultManager.CreateFolderResult(filename, path, path, query); + else { - Title = filename, - SubTitle = path, - IcoPath = fileType == "Directory" ? Constants.FolderImagePath : Constants.FileImagePath, - Action = c => - { - try - { - FilesFolders.OpenPath(path); - } - catch (Win32Exception) - { - _context.API.ShowMsg("Explorer plugin: ", "Unable to open the selected file", string.Empty); //<========= - } - - return true; - } - }; + return ResultManager.CreateFileResult(path, query); + } } - internal List WindowsIndexSearch(string searchString, string connectionString, Func constructQuery) + internal List WindowsIndexSearch(string searchString, string connectionString, Func constructQuery, Query query) { var regexMatch = Regex.Match(searchString, ReservedStringPattern); @@ -107,7 +95,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex lock (_lock) { var constructedQuery = constructQuery(searchString); - return ExecuteWindowsIndexSearch(constructedQuery, connectionString); + return ExecuteWindowsIndexSearch(constructedQuery, connectionString, query); } }