From 5b2f06bf106a6f34983a7d4b42d874f615f96b05 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Tue, 26 May 2020 21:55:07 +1000 Subject: [PATCH] add logic for index search to search with partial item name --- .../Search/SearchManager.cs | 15 ++++++++------- .../Search/WindowsIndex/QueryConstructor.cs | 15 ++++++++++++++- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs index 2b5744b19..1bca58366 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs @@ -1,4 +1,4 @@ -using Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo; +using Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo; using Flow.Launcher.Plugin.Explorer.Search.QuickFolderLinks; using Flow.Launcher.Plugin.Explorer.Search.WindowsIndex; using Flow.Launcher.Plugin.SharedCommands; @@ -54,13 +54,14 @@ namespace Flow.Launcher.Plugin.Explorer.Search return new List(); results.Add(currentFolderResult); - DirectoryInfoClassSearch, - WindowsIndexExists, - query, - querySearch); - } - return WindowsIndexFilesAndFoldersSearch(query, querySearch); + results.AddRange(TopLevelFolderSearchBehaviour(WindowsIndexTopLevelFolderSearch, + DirectoryInfoClassSearch, + WindowsIndexExists, + query, + querySearch)); + + return results; } private List DirectoryInfoClassSearch(Query query, string querySearch) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs index 2c2f197c0..cbf896d26 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs @@ -51,7 +51,20 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex /// public string QueryWhereRestrictionsForTopLevelDirectorySearch(string path) { - return $"directory='file:{path}'"; + var directoryWhereRestriction = $"directory='file:"; + + if (path.EndsWith("\\")) + return directoryWhereRestriction + $"{path}'"; + + var indexOfSeparator = path.LastIndexOf('\\'); + + var itemName = path.Substring(indexOfSeparator + 1); + + var previousLevelDirectory = path.Substring(0, indexOfSeparator); + + return $"(System.FileName LIKE '{itemName}%' " + + $"OR CONTAINS(System.FileName,'\"{itemName}*\"',1033)) AND " + + directoryWhereRestriction + $"{previousLevelDirectory}'"; } ///