diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs index 2953e4329..a299f24c3 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs @@ -14,9 +14,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search internal const string DefaultFolderSubtitleString = "Ctrl + Enter to open the directory"; - internal static readonly char[] SpecialSearchChars = new char[] - { - '?', '*', '>' - }; + internal const char AllFilesFolderSearchWildcard = '>'; + + internal const char DirectorySeperator = '\\'; } } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs index c535fef99..f68e8143e 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs @@ -21,7 +21,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo { var criteria = ConstructSearchCriteria(search); - if (search.LastIndexOf('>') > search.LastIndexOf('\\')) + if (search.LastIndexOf(Constants.AllFilesFolderSearchWildcard) > search.LastIndexOf(Constants.DirectorySeperator)) return DirectorySearch(SearchOption.AllDirectories, query, search, criteria); return DirectorySearch(SearchOption.TopDirectoryOnly, query, search, criteria); @@ -31,13 +31,13 @@ namespace Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo { string incompleteName = ""; - if (!search.EndsWith("\\")) + if (!search.EndsWith(Constants.DirectorySeperator)) { - var indexOfSeparator = search.LastIndexOf('\\'); + var indexOfSeparator = search.LastIndexOf(Constants.DirectorySeperator); incompleteName = search.Substring(indexOfSeparator + 1).ToLower(); - if (incompleteName.StartsWith('>')) + if (incompleteName.StartsWith(Constants.AllFilesFolderSearchWildcard)) incompleteName = "*" + incompleteName.Substring(1); } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs index 50791251f..ec9c793ac 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs @@ -35,7 +35,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search } } - string changeTo = path.EndsWith("\\") ? path : path + "\\"; + string changeTo = path.EndsWith(Constants.DirectorySeperator) ? path : path + Constants.DirectorySeperator; Main.Context.API.ChangeQuery(string.IsNullOrEmpty(query.ActionKeyword) ? changeTo : query.ActionKeyword + " " + changeTo); @@ -56,7 +56,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search } else { - folderName = folderName.TrimEnd('\\').Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.None).Last(); + folderName = folderName.TrimEnd(Constants.DirectorySeperator).Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.None).Last(); } var firstResult = ""; diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs index 8a6c0f798..e037cc8c9 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs @@ -68,14 +68,14 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex private string QueryWhereRestrictionsFromLocationPath(string path, string searchDepth) { - if (path.EndsWith("\\")) + if (path.EndsWith(Constants.DirectorySeperator)) return searchDepth + $"{path}'"; - var indexOfSeparator = path.LastIndexOf('\\'); + var indexOfSeparator = path.LastIndexOf(Constants.DirectorySeperator); var itemName = path.Substring(indexOfSeparator + 1); - if (itemName.StartsWith('>')) + if (itemName.StartsWith(Constants.AllFilesFolderSearchWildcard)) itemName = itemName.Substring(1); var previousLevelDirectory = path.Substring(0, indexOfSeparator); @@ -95,7 +95,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex { string query = "SELECT TOP " + _settings.MaxResult + $" {CreateBaseQuery().QuerySelectColumns} FROM {SystemIndex} WHERE "; - if (path.IndexOfAny(Constants.SpecialSearchChars) >= 0) + if (path.LastIndexOf(Constants.AllFilesFolderSearchWildcard) > path.LastIndexOf(Constants.DirectorySeperator)) return query + QueryWhereRestrictionsForTopLevelDirectoryAllFilesAndFoldersSearch(path); return query + QueryWhereRestrictionsForTopLevelDirectorySearch(path);