mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Add search hotkeys to Constants
This commit is contained in:
parent
9bce1a593e
commit
b5e9ec3a9f
2 changed files with 32 additions and 7 deletions
|
|
@ -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[]
|
||||
{
|
||||
'?', '*', '>'
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,20 +51,41 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
|
|||
///</summary>
|
||||
public string QueryWhereRestrictionsForTopLevelDirectorySearch(string path)
|
||||
{
|
||||
var directoryWhereRestriction = $"directory='file:";
|
||||
var searchDepth = $"directory='file:";
|
||||
|
||||
return QueryWhereRestrictionsFromLocationPath(path, searchDepth);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Set the required WHERE clause restriction to search all files and subfolders of a specified directory.
|
||||
///</summary>
|
||||
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}'";
|
||||
}
|
||||
|
||||
///<summary>
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
|
|
|
|||
Loading…
Reference in a new issue