diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs
index 17070fbc1..20d8b8261 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Text;
@@ -12,6 +12,9 @@ namespace Flow.Launcher.Plugin.Explorer.Search
public const string CopyImagePath = "Images\\copy.png";
public const string IndexImagePath = "Images\\index.png";
- public const string DefaultFolderSubtitleString = "Ctrl + Enter to open the directory";
+ internal static readonly char[] SpecialSearchChars = new char[]
+ {
+ '?', '*', '>'
+ };
}
}
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs
index cbf896d26..8a6c0f798 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs
@@ -51,20 +51,41 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
///
public string QueryWhereRestrictionsForTopLevelDirectorySearch(string path)
{
- var directoryWhereRestriction = $"directory='file:";
+ var searchDepth = $"directory='file:";
+ return QueryWhereRestrictionsFromLocationPath(path, searchDepth);
+ }
+
+ ///
+ /// Set the required WHERE clause restriction to search all files and subfolders of a specified directory.
+ ///
+ public string QueryWhereRestrictionsForTopLevelDirectoryAllFilesAndFoldersSearch(string path)
+ {
+ var searchDepth = $"scope='file:";
+
+ return QueryWhereRestrictionsFromLocationPath(path, searchDepth);
+ }
+
+ private string QueryWhereRestrictionsFromLocationPath(string path, string searchDepth)
+ {
if (path.EndsWith("\\"))
- return directoryWhereRestriction + $"{path}'";
+ return searchDepth + $"{path}'";
var indexOfSeparator = path.LastIndexOf('\\');
var itemName = path.Substring(indexOfSeparator + 1);
+ if (itemName.StartsWith('>'))
+ itemName = itemName.Substring(1);
+
var previousLevelDirectory = path.Substring(0, indexOfSeparator);
+ if (string.IsNullOrEmpty(itemName))
+ return searchDepth + $"{previousLevelDirectory}'";
+
return $"(System.FileName LIKE '{itemName}%' " +
$"OR CONTAINS(System.FileName,'\"{itemName}*\"',1033)) AND " +
- directoryWhereRestriction + $"{previousLevelDirectory}'";
+ searchDepth + $"{previousLevelDirectory}'";
}
///
@@ -74,9 +95,10 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
{
string query = "SELECT TOP " + _settings.MaxResult + $" {CreateBaseQuery().QuerySelectColumns} FROM {SystemIndex} WHERE ";
- query += QueryWhereRestrictionsForTopLevelDirectorySearch(path);
+ if (path.IndexOfAny(Constants.SpecialSearchChars) >= 0)
+ return query + QueryWhereRestrictionsForTopLevelDirectoryAllFilesAndFoldersSearch(path);
- return query;
+ return query + QueryWhereRestrictionsForTopLevelDirectorySearch(path);
}
///