Merge pull request #309 from taooceros/ExplorerDirectorySearchWithIndexFix

Fix unrecognized path
This commit is contained in:
Jeremy Wu 2021-01-24 21:21:36 +11:00 committed by GitHub
commit d0af7a1b75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 18 deletions

View file

@ -146,31 +146,23 @@ namespace Flow.Launcher.Plugin.SharedCommands
/// This checks whether a given string is a directory path or network location string.
/// It does not check if location actually exists.
///</summary>
public static bool IsLocationPathString(string querySearchString)
public static bool IsLocationPathString(this string querySearchString)
{
if (string.IsNullOrEmpty(querySearchString))
if (string.IsNullOrEmpty(querySearchString) || querySearchString.Length < 3)
return false;
// // shared folder location, and not \\\location\
if (querySearchString.Length >= 3
&& querySearchString.StartsWith(@"\\")
&& char.IsLetter(querySearchString[2]))
if (querySearchString.StartsWith(@"\\")
&& querySearchString[2] != '\\')
return true;
// c:\
if (querySearchString.Length == 3
&& char.IsLetter(querySearchString[0])
if (char.IsLetter(querySearchString[0])
&& querySearchString[1] == ':'
&& querySearchString[2] == '\\')
return true;
// c:\\
if (querySearchString.Length >= 4
&& char.IsLetter(querySearchString[0])
&& querySearchString[1] == ':'
&& querySearchString[2] == '\\'
&& char.IsLetter(querySearchString[3]))
return true;
{
return querySearchString.Length == 3 || querySearchString[3] != '\\';
}
return false;
}

View file

@ -240,6 +240,9 @@ namespace Flow.Launcher.Test.Plugins
[TestCase(@"cc:\", false)]
[TestCase(@"\\\SomeNetworkLocation\", false)]
[TestCase("RandomFile", false)]
[TestCase(@"c:\>*", true)]
[TestCase(@"c:\>", true)]
[TestCase(@"c:\SomeLocation\SomeOtherLocation\>", true)]
public void WhenGivenQuerySearchString_ThenShouldIndicateIfIsLocationPathString(string querySearchString, bool expectedResult)
{
// When, Given

View file

@ -58,7 +58,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
// Query is a location path with a full environment variable, eg. %appdata%\somefolder\
var isEnvironmentVariablePath = querySearch[1..].Contains("%\\");
if (!FilesFolders.IsLocationPathString(querySearch) && !isEnvironmentVariablePath)
if (!querySearch.IsLocationPathString() && !isEnvironmentVariablePath)
{
results.AddRange(await WindowsIndexFilesAndFoldersSearchAsync(query, querySearch, token).ConfigureAwait(false));
@ -70,6 +70,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
if (isEnvironmentVariablePath)
locationPath = EnvironmentVariables.TranslateEnvironmentVariablePath(locationPath);
// Check that actual location exists, otherwise directory search will throw directory not found exception
if (!FilesFolders.LocationExists(FilesFolders.ReturnPreviousDirectoryIfIncompleteString(locationPath)))
return results;

View file

@ -7,7 +7,7 @@
"Name": "Explorer",
"Description": "Search and manage files and folders. Explorer utilises Windows Index Search",
"Author": "Jeremy Wu",
"Version": "1.4.0",
"Version": "1.4.1",
"Language": "csharp",
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
"ExecuteFileName": "Flow.Launcher.Plugin.Explorer.dll",