Merge pull request #1788 from Flow-Launcher/explorer_working_dir

fix explorer setting UseLocationAsWorkingDir
This commit is contained in:
VictoriousRaptor 2023-01-13 15:28:16 +08:00 committed by GitHub
commit 0e0bc1e39f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 21 deletions

View file

@ -83,4 +83,6 @@ btn
otf
searchplugin
Noresult
wpftk
wpftk
mkv
flac

View file

@ -32,7 +32,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
internal const string DefaultContentSearchActionKeyword = "doc:";
internal const char DirectorySeperator = '\\';
internal const char DirectorySeparator = '\\';
internal const string WindowsIndexingOptions = "srchadmin.dll";

View file

@ -15,7 +15,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo
var criteria = ConstructSearchCriteria(search);
if (search.LastIndexOf(Constants.AllFilesFolderSearchWildcard) >
search.LastIndexOf(Constants.DirectorySeperator))
search.LastIndexOf(Constants.DirectorySeparator))
return DirectorySearch(new EnumerationOptions
{
RecurseSubdirectories = true
@ -29,9 +29,9 @@ namespace Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo
{
string incompleteName = "";
if (!search.EndsWith(Constants.DirectorySeperator))
if (!search.EndsWith(Constants.DirectorySeparator))
{
var indexOfSeparator = search.LastIndexOf(Constants.DirectorySeperator);
var indexOfSeparator = search.LastIndexOf(Constants.DirectorySeparator);
incompleteName = search[(indexOfSeparator + 1)..].ToLower();

View file

@ -15,7 +15,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks
{
get
{
var path = Path.EndsWith(Constants.DirectorySeperator) ? Path[0..^1] : Path;
var path = Path.EndsWith(Constants.DirectorySeparator) ? Path[0..^1] : Path;
if (path.EndsWith(':'))
return path[0..^1] + " Drive";

View file

@ -27,8 +27,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search
var usePathSearchActionKeyword = Settings.PathSearchKeywordEnabled && !Settings.SearchActionKeywordEnabled;
var pathSearchActionKeyword = Settings.PathSearchActionKeyword == Query.GlobalPluginWildcardSign
? string.Empty
var pathSearchActionKeyword = Settings.PathSearchActionKeyword == Query.GlobalPluginWildcardSign
? string.Empty
: $"{Settings.PathSearchActionKeyword} ";
var searchActionKeyword = Settings.SearchActionKeyword == Query.GlobalPluginWildcardSign
@ -36,12 +36,12 @@ namespace Flow.Launcher.Plugin.Explorer.Search
: $"{Settings.SearchActionKeyword} ";
var keyword = usePathSearchActionKeyword ? pathSearchActionKeyword : searchActionKeyword;
var formatted_path = path;
if (type == ResultType.Folder)
// the seperator is needed so when navigating the folder structure contents of the folder are listed
formatted_path = path.EndsWith(Constants.DirectorySeperator) ? path : path + Constants.DirectorySeperator;
// the separator is needed so when navigating the folder structure contents of the folder are listed
formatted_path = path.EndsWith(Constants.DirectorySeparator) ? path : path + Constants.DirectorySeparator;
return $"{keyword}{formatted_path}";
}
@ -49,8 +49,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search
public static string GetAutoCompleteText(string title, Query query, string path, ResultType resultType)
{
return !Settings.PathSearchKeywordEnabled && !Settings.SearchActionKeywordEnabled
? $"{query.ActionKeyword} {title}" // Only Quick Access action keyword is used in this scenario
: GetPathWithActionKeyword(path, resultType, query.ActionKeyword);
? $"{query.ActionKeyword} {title}" // Only Quick Access action keyword is used in this scenario
: GetPathWithActionKeyword(path, resultType, query.ActionKeyword);
}
public static Result CreateResult(Query query, SearchResult result)
@ -187,9 +187,9 @@ namespace Flow.Launcher.Plugin.Explorer.Search
internal static Result CreateOpenCurrentFolderResult(string path, string actionKeyword, bool windowsIndexed = false)
{
// Path passed from PathSearchAsync ends with Constants.DirectorySeperator ('\'), need to remove the seperator
// Path passed from PathSearchAsync ends with Constants.DirectorySeparator ('\'), need to remove the separator
// so it's consistent with folder results returned by index search which does not end with one
var folderPath = path.TrimEnd(Constants.DirectorySeperator);
var folderPath = path.TrimEnd(Constants.DirectorySeparator);
return new Result
{
@ -215,9 +215,9 @@ namespace Flow.Launcher.Plugin.Explorer.Search
internal static Result CreateFileResult(string filePath, Query query, int score = 0, bool windowsIndexed = false)
{
Result.PreviewInfo preview = IsMedia(Path.GetExtension(filePath)) ? new Result.PreviewInfo {
IsMedia = true,
PreviewImagePath = filePath,
Result.PreviewInfo preview = IsMedia(Path.GetExtension(filePath)) ? new Result.PreviewInfo
{
IsMedia = true, PreviewImagePath = filePath,
} : Result.PreviewInfo.Default;
var title = Path.GetFileName(filePath);
@ -246,6 +246,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
{
FileName = filePath,
UseShellExecute = true,
WorkingDirectory = Settings.UseLocationAsWorkingDir ? Path.GetDirectoryName(filePath) : string.Empty,
Verb = "runas",
});
}
@ -286,8 +287,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search
public static bool IsMedia(string extension)
{
if (string.IsNullOrEmpty(extension))
{
return false;
{
return false;
}
else
{
@ -295,7 +296,10 @@ namespace Flow.Launcher.Plugin.Explorer.Search
}
}
public static readonly string[] MediaExtensions = { ".jpg", ".png", ".avi", ".mkv", ".bmp", ".gif", ".wmv", ".mp3", ".flac", ".mp4" };
public static readonly string[] MediaExtensions =
{
".jpg", ".png", ".avi", ".mkv", ".bmp", ".gif", ".wmv", ".mp3", ".flac", ".mp4"
};
}
public enum ResultType