Skip to content

Commit 0e0bc1e

Browse files
Merge pull request #1788 from Flow-Launcher/explorer_working_dir
fix explorer setting UseLocationAsWorkingDir
2 parents 29282e4 + 457e413 commit 0e0bc1e

File tree

5 files changed

+27
-21
lines changed

5 files changed

+27
-21
lines changed

.github/actions/spelling/expect.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,6 @@ btn
8383
otf
8484
searchplugin
8585
Noresult
86-
wpftk
86+
wpftk
87+
mkv
88+
flac

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ internal static class Constants
3232

3333
internal const string DefaultContentSearchActionKeyword = "doc:";
3434

35-
internal const char DirectorySeperator = '\\';
35+
internal const char DirectorySeparator = '\\';
3636

3737
internal const string WindowsIndexingOptions = "srchadmin.dll";
3838

Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ internal static IEnumerable<SearchResult> TopLevelDirectorySearch(Query query, s
1515
var criteria = ConstructSearchCriteria(search);
1616

1717
if (search.LastIndexOf(Constants.AllFilesFolderSearchWildcard) >
18-
search.LastIndexOf(Constants.DirectorySeperator))
18+
search.LastIndexOf(Constants.DirectorySeparator))
1919
return DirectorySearch(new EnumerationOptions
2020
{
2121
RecurseSubdirectories = true
@@ -29,9 +29,9 @@ public static string ConstructSearchCriteria(string search)
2929
{
3030
string incompleteName = "";
3131

32-
if (!search.EndsWith(Constants.DirectorySeperator))
32+
if (!search.EndsWith(Constants.DirectorySeparator))
3333
{
34-
var indexOfSeparator = search.LastIndexOf(Constants.DirectorySeperator);
34+
var indexOfSeparator = search.LastIndexOf(Constants.DirectorySeparator);
3535

3636
incompleteName = search[(indexOfSeparator + 1)..].ToLower();
3737

Plugins/Flow.Launcher.Plugin.Explorer/Search/QuickAccessLinks/AccessLink.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public string Name
1515
{
1616
get
1717
{
18-
var path = Path.EndsWith(Constants.DirectorySeperator) ? Path[0..^1] : Path;
18+
var path = Path.EndsWith(Constants.DirectorySeparator) ? Path[0..^1] : Path;
1919

2020
if (path.EndsWith(':'))
2121
return path[0..^1] + " Drive";

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

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,30 @@ public static string GetPathWithActionKeyword(string path, ResultType type, stri
2727

2828
var usePathSearchActionKeyword = Settings.PathSearchKeywordEnabled && !Settings.SearchActionKeywordEnabled;
2929

30-
var pathSearchActionKeyword = Settings.PathSearchActionKeyword == Query.GlobalPluginWildcardSign
31-
? string.Empty
30+
var pathSearchActionKeyword = Settings.PathSearchActionKeyword == Query.GlobalPluginWildcardSign
31+
? string.Empty
3232
: $"{Settings.PathSearchActionKeyword} ";
3333

3434
var searchActionKeyword = Settings.SearchActionKeyword == Query.GlobalPluginWildcardSign
3535
? string.Empty
3636
: $"{Settings.SearchActionKeyword} ";
3737

3838
var keyword = usePathSearchActionKeyword ? pathSearchActionKeyword : searchActionKeyword;
39-
39+
4040
var formatted_path = path;
4141

4242
if (type == ResultType.Folder)
43-
// the seperator is needed so when navigating the folder structure contents of the folder are listed
44-
formatted_path = path.EndsWith(Constants.DirectorySeperator) ? path : path + Constants.DirectorySeperator;
43+
// the separator is needed so when navigating the folder structure contents of the folder are listed
44+
formatted_path = path.EndsWith(Constants.DirectorySeparator) ? path : path + Constants.DirectorySeparator;
4545

4646
return $"{keyword}{formatted_path}";
4747
}
4848

4949
public static string GetAutoCompleteText(string title, Query query, string path, ResultType resultType)
5050
{
5151
return !Settings.PathSearchKeywordEnabled && !Settings.SearchActionKeywordEnabled
52-
? $"{query.ActionKeyword} {title}" // Only Quick Access action keyword is used in this scenario
53-
: GetPathWithActionKeyword(path, resultType, query.ActionKeyword);
52+
? $"{query.ActionKeyword} {title}" // Only Quick Access action keyword is used in this scenario
53+
: GetPathWithActionKeyword(path, resultType, query.ActionKeyword);
5454
}
5555

5656
public static Result CreateResult(Query query, SearchResult result)
@@ -187,9 +187,9 @@ private static string ToReadableSize(long pDrvSize, int pi)
187187

188188
internal static Result CreateOpenCurrentFolderResult(string path, string actionKeyword, bool windowsIndexed = false)
189189
{
190-
// Path passed from PathSearchAsync ends with Constants.DirectorySeperator ('\'), need to remove the seperator
190+
// Path passed from PathSearchAsync ends with Constants.DirectorySeparator ('\'), need to remove the separator
191191
// so it's consistent with folder results returned by index search which does not end with one
192-
var folderPath = path.TrimEnd(Constants.DirectorySeperator);
192+
var folderPath = path.TrimEnd(Constants.DirectorySeparator);
193193

194194
return new Result
195195
{
@@ -215,9 +215,9 @@ internal static Result CreateOpenCurrentFolderResult(string path, string actionK
215215

216216
internal static Result CreateFileResult(string filePath, Query query, int score = 0, bool windowsIndexed = false)
217217
{
218-
Result.PreviewInfo preview = IsMedia(Path.GetExtension(filePath)) ? new Result.PreviewInfo {
219-
IsMedia = true,
220-
PreviewImagePath = filePath,
218+
Result.PreviewInfo preview = IsMedia(Path.GetExtension(filePath)) ? new Result.PreviewInfo
219+
{
220+
IsMedia = true, PreviewImagePath = filePath,
221221
} : Result.PreviewInfo.Default;
222222

223223
var title = Path.GetFileName(filePath);
@@ -246,6 +246,7 @@ internal static Result CreateFileResult(string filePath, Query query, int score
246246
{
247247
FileName = filePath,
248248
UseShellExecute = true,
249+
WorkingDirectory = Settings.UseLocationAsWorkingDir ? Path.GetDirectoryName(filePath) : string.Empty,
249250
Verb = "runas",
250251
});
251252
}
@@ -286,16 +287,19 @@ internal static Result CreateFileResult(string filePath, Query query, int score
286287
public static bool IsMedia(string extension)
287288
{
288289
if (string.IsNullOrEmpty(extension))
289-
{
290-
return false;
290+
{
291+
return false;
291292
}
292293
else
293294
{
294295
return MediaExtensions.Contains(extension.ToLowerInvariant());
295296
}
296297
}
297298

298-
public static readonly string[] MediaExtensions = { ".jpg", ".png", ".avi", ".mkv", ".bmp", ".gif", ".wmv", ".mp3", ".flac", ".mp4" };
299+
public static readonly string[] MediaExtensions =
300+
{
301+
".jpg", ".png", ".avi", ".mkv", ".bmp", ".gif", ".wmv", ".mp3", ".flac", ".mp4"
302+
};
299303
}
300304

301305
public enum ResultType

0 commit comments

Comments
 (0)