Skip to content

Commit d0af7a1

Browse files
authored
Merge pull request #309 from taooceros/ExplorerDirectorySearchWithIndexFix
Fix unrecognized path
2 parents 8c84e63 + 2968a59 commit d0af7a1

File tree

4 files changed

+14
-18
lines changed

4 files changed

+14
-18
lines changed

Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -146,31 +146,23 @@ public static void OpenContainingFolder(string path)
146146
/// This checks whether a given string is a directory path or network location string.
147147
/// It does not check if location actually exists.
148148
///</summary>
149-
public static bool IsLocationPathString(string querySearchString)
149+
public static bool IsLocationPathString(this string querySearchString)
150150
{
151-
if (string.IsNullOrEmpty(querySearchString))
151+
if (string.IsNullOrEmpty(querySearchString) || querySearchString.Length < 3)
152152
return false;
153153

154154
// // shared folder location, and not \\\location\
155-
if (querySearchString.Length >= 3
156-
&& querySearchString.StartsWith(@"\\")
157-
&& char.IsLetter(querySearchString[2]))
155+
if (querySearchString.StartsWith(@"\\")
156+
&& querySearchString[2] != '\\')
158157
return true;
159158

160159
// c:\
161-
if (querySearchString.Length == 3
162-
&& char.IsLetter(querySearchString[0])
160+
if (char.IsLetter(querySearchString[0])
163161
&& querySearchString[1] == ':'
164162
&& querySearchString[2] == '\\')
165-
return true;
166-
167-
// c:\\
168-
if (querySearchString.Length >= 4
169-
&& char.IsLetter(querySearchString[0])
170-
&& querySearchString[1] == ':'
171-
&& querySearchString[2] == '\\'
172-
&& char.IsLetter(querySearchString[3]))
173-
return true;
163+
{
164+
return querySearchString.Length == 3 || querySearchString[3] != '\\';
165+
}
174166

175167
return false;
176168
}

Flow.Launcher.Test/Plugins/ExplorerTest.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ public void GivenQuery_WhenActionKeywordForFileContentSearchExists_ThenFileConte
240240
[TestCase(@"cc:\", false)]
241241
[TestCase(@"\\\SomeNetworkLocation\", false)]
242242
[TestCase("RandomFile", false)]
243+
[TestCase(@"c:\>*", true)]
244+
[TestCase(@"c:\>", true)]
245+
[TestCase(@"c:\SomeLocation\SomeOtherLocation\>", true)]
243246
public void WhenGivenQuerySearchString_ThenShouldIndicateIfIsLocationPathString(string querySearchString, bool expectedResult)
244247
{
245248
// When, Given

Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ internal async Task<List<Result>> SearchAsync(Query query, CancellationToken tok
5858
// Query is a location path with a full environment variable, eg. %appdata%\somefolder\
5959
var isEnvironmentVariablePath = querySearch[1..].Contains("%\\");
6060

61-
if (!FilesFolders.IsLocationPathString(querySearch) && !isEnvironmentVariablePath)
61+
if (!querySearch.IsLocationPathString() && !isEnvironmentVariablePath)
6262
{
6363
results.AddRange(await WindowsIndexFilesAndFoldersSearchAsync(query, querySearch, token).ConfigureAwait(false));
6464

@@ -70,6 +70,7 @@ internal async Task<List<Result>> SearchAsync(Query query, CancellationToken tok
7070
if (isEnvironmentVariablePath)
7171
locationPath = EnvironmentVariables.TranslateEnvironmentVariablePath(locationPath);
7272

73+
// Check that actual location exists, otherwise directory search will throw directory not found exception
7374
if (!FilesFolders.LocationExists(FilesFolders.ReturnPreviousDirectoryIfIncompleteString(locationPath)))
7475
return results;
7576

Plugins/Flow.Launcher.Plugin.Explorer/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"Name": "Explorer",
88
"Description": "Search and manage files and folders. Explorer utilises Windows Index Search",
99
"Author": "Jeremy Wu",
10-
"Version": "1.4.0",
10+
"Version": "1.4.1",
1111
"Language": "csharp",
1212
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
1313
"ExecuteFileName": "Flow.Launcher.Plugin.Explorer.dll",

0 commit comments

Comments
 (0)