mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
fix TopLevelDirectory search activation
This commit is contained in:
parent
c7642b73c0
commit
0c53d76fec
4 changed files with 36 additions and 12 deletions
|
|
@ -185,5 +185,23 @@ namespace Flow.Launcher.Plugin.SharedCommands
|
||||||
|
|
||||||
return previousDirectoryPath;
|
return previousDirectoryPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// Gets the previous level directory from a path string.
|
||||||
|
/// Does not check that previous level directory exists and returns
|
||||||
|
/// passed in string if is complete path
|
||||||
|
///</summary>
|
||||||
|
public static string GetPreviousLevelDirectoryIfPathIncomplete(string path)
|
||||||
|
{
|
||||||
|
if (!path.EndsWith("\\"))
|
||||||
|
{
|
||||||
|
// not full path, get previous level directory string
|
||||||
|
var indexOfSeparator = path.LastIndexOf('\\');
|
||||||
|
|
||||||
|
return path.Substring(0, indexOfSeparator + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -228,6 +228,19 @@ namespace Flow.Launcher.Test.Plugins
|
||||||
$"Actual path string is {previousDirectoryPath} {Environment.NewLine}");
|
$"Actual path string is {previousDirectoryPath} {Environment.NewLine}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestCase(@"C:\NonExistentFolder\SomeApp", @"C:\NonExistentFolder\")]
|
||||||
|
[TestCase(@"C:\NonExistentFolder\SomeApp\", @"C:\NonExistentFolder\SomeApp\")]
|
||||||
|
public void WhenGivenAPath_ThenShouldReturnThePreviousDirectoryPathIfIncompleteOrOriginalString(
|
||||||
|
string path, string expectedString)
|
||||||
|
{
|
||||||
|
var returnedPath = FilesFolders.GetPreviousLevelDirectoryIfPathIncomplete(path);
|
||||||
|
|
||||||
|
//Then
|
||||||
|
Assert.IsTrue(returnedPath == expectedString,
|
||||||
|
$"Expected path string: {expectedString} {Environment.NewLine} " +
|
||||||
|
$"Actual path string is {returnedPath} {Environment.NewLine}");
|
||||||
|
}
|
||||||
|
|
||||||
[TestCase("c:\\SomeFolder\\>", "scope='file:c:\\SomeFolder'")]
|
[TestCase("c:\\SomeFolder\\>", "scope='file:c:\\SomeFolder'")]
|
||||||
[TestCase("c:\\SomeFolder\\>SomeName", "(System.FileName LIKE 'SomeName%' " +
|
[TestCase("c:\\SomeFolder\\>SomeName", "(System.FileName LIKE 'SomeName%' " +
|
||||||
"OR CONTAINS(System.FileName,'\"SomeName*\"',1033)) AND " +
|
"OR CONTAINS(System.FileName,'\"SomeName*\"',1033)) AND " +
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo
|
||||||
{
|
{
|
||||||
var criteria = ConstructSearchCriteria(search);
|
var criteria = ConstructSearchCriteria(search);
|
||||||
|
|
||||||
if (search.IndexOfAny(Constants.SpecialSearchChars) >= 0)
|
if (search.LastIndexOf('>') > search.LastIndexOf('\\'))
|
||||||
return DirectorySearch(SearchOption.AllDirectories, query, search, criteria);
|
return DirectorySearch(SearchOption.AllDirectories, query, search, criteria);
|
||||||
|
|
||||||
return DirectorySearch(SearchOption.TopDirectoryOnly, query, search, criteria);
|
return DirectorySearch(SearchOption.TopDirectoryOnly, query, search, criteria);
|
||||||
|
|
@ -33,12 +33,11 @@ namespace Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo
|
||||||
|
|
||||||
if (!search.EndsWith("\\"))
|
if (!search.EndsWith("\\"))
|
||||||
{
|
{
|
||||||
// not full path, get previous level directory string
|
|
||||||
var indexOfSeparator = search.LastIndexOf('\\');
|
var indexOfSeparator = search.LastIndexOf('\\');
|
||||||
|
|
||||||
incompleteName = search.Substring(indexOfSeparator + 1).ToLower();
|
incompleteName = search.Substring(indexOfSeparator + 1).ToLower();
|
||||||
|
|
||||||
if (incompleteName.StartsWith(">"))
|
if (incompleteName.StartsWith('>'))
|
||||||
incompleteName = "*" + incompleteName.Substring(1);
|
incompleteName = "*" + incompleteName.Substring(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -51,15 +50,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo
|
||||||
{
|
{
|
||||||
var results = new List<Result>();
|
var results = new List<Result>();
|
||||||
|
|
||||||
var path = search;
|
var path = FilesFolders.GetPreviousLevelDirectoryIfPathIncomplete(search);
|
||||||
|
|
||||||
if (!search.EndsWith("\\"))
|
|
||||||
{
|
|
||||||
// not full path, get previous level directory string
|
|
||||||
var indexOfSeparator = search.LastIndexOf('\\');
|
|
||||||
|
|
||||||
path = search.Substring(0, indexOfSeparator + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
var folderList = new List<Result>();
|
var folderList = new List<Result>();
|
||||||
var fileList = new List<Result>();
|
var fileList = new List<Result>();
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
||||||
|
|
||||||
private bool WindowsIndexExists(string path)
|
private bool WindowsIndexExists(string path)
|
||||||
{
|
{
|
||||||
|
path = FilesFolders.GetPreviousLevelDirectoryIfPathIncomplete(path);
|
||||||
|
|
||||||
return _indexSearch.PathIsIndexed(path);
|
return _indexSearch.PathIsIndexed(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue