add logic for index search to search with partial item name

This commit is contained in:
Jeremy Wu 2020-05-26 21:55:07 +10:00
parent ea9992475e
commit 5b2f06bf10
2 changed files with 22 additions and 8 deletions

View file

@ -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<Result>();
results.Add(currentFolderResult);
DirectoryInfoClassSearch,
WindowsIndexExists,
query,
querySearch);
}
return WindowsIndexFilesAndFoldersSearch(query, querySearch);
results.AddRange(TopLevelFolderSearchBehaviour(WindowsIndexTopLevelFolderSearch,
DirectoryInfoClassSearch,
WindowsIndexExists,
query,
querySearch));
return results;
}
private List<Result> DirectoryInfoClassSearch(Query query, string querySearch)

View file

@ -51,7 +51,20 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
///</summary>
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}'";
}
///<summary>