Merge branch 'dev' into fix_dup_results_explorer

This commit is contained in:
VictoriousRaptor 2022-12-12 14:29:37 +08:00 committed by GitHub
commit 48629502f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 14 deletions

View file

@ -21,16 +21,15 @@ namespace Flow.Launcher.Plugin.Explorer.Search
Settings = settings; Settings = settings;
} }
private static string GetPathWithActionKeyword(string path, ResultType type) private static string GetPathWithActionKeyword(string path, ResultType type, string actionKeyword)
{ {
// one of it is enabled // Query.ActionKeyword is string.Empty when Global Action Keyword ('*') is used
var keyword = Settings.SearchActionKeywordEnabled ? Settings.SearchActionKeyword : Settings.PathSearchActionKeyword; var keyword = actionKeyword != string.Empty ? actionKeyword + " " : string.Empty;
keyword = keyword == Query.GlobalPluginWildcardSign ? string.Empty : keyword + " ";
var formatted_path = path; var formatted_path = path;
if (type == ResultType.Folder) 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; formatted_path = path.EndsWith(Constants.DirectorySeperator) ? path : path + Constants.DirectorySeperator;
return $"{keyword}{formatted_path}"; return $"{keyword}{formatted_path}";
@ -55,7 +54,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
Title = title, Title = title,
IcoPath = path, IcoPath = path,
SubTitle = Path.GetDirectoryName(path), SubTitle = Path.GetDirectoryName(path),
AutoCompleteText = GetPathWithActionKeyword(path, ResultType.Folder), AutoCompleteText = GetPathWithActionKeyword(path, ResultType.Folder, query.ActionKeyword),
TitleHighlightData = StringMatcher.FuzzySearch(query.Search, title).MatchData, TitleHighlightData = StringMatcher.FuzzySearch(query.Search, title).MatchData,
CopyText = path, CopyText = path,
Action = c => Action = c =>
@ -74,7 +73,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
} }
} }
Context.API.ChangeQuery(GetPathWithActionKeyword(path, ResultType.Folder)); Context.API.ChangeQuery(GetPathWithActionKeyword(path, ResultType.Folder, query.ActionKeyword));
return false; return false;
}, },
@ -90,7 +89,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
}; };
} }
internal static Result CreateDriveSpaceDisplayResult(string path, bool windowsIndexed = false) internal static Result CreateDriveSpaceDisplayResult(string path, string actionKeyword, bool windowsIndexed = false)
{ {
var progressBarColor = "#26a0da"; var progressBarColor = "#26a0da";
var title = string.Empty; // hide title when use progress bar, var title = string.Empty; // hide title when use progress bar,
@ -109,7 +108,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
{ {
Title = title, Title = title,
SubTitle = subtitle, SubTitle = subtitle,
AutoCompleteText = GetPathWithActionKeyword(path, ResultType.Folder), AutoCompleteText = GetPathWithActionKeyword(path, ResultType.Folder, actionKeyword),
IcoPath = path, IcoPath = path,
Score = 500, Score = 500,
ProgressBar = progressValue, ProgressBar = progressValue,
@ -166,7 +165,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
return returnStr; return returnStr;
} }
internal static Result CreateOpenCurrentFolderResult(string path, bool windowsIndexed = false) 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.DirectorySeperator ('\'), need to remove the seperator
// so it's consistent with folder results returned by index search which does not end with one // so it's consistent with folder results returned by index search which does not end with one
@ -190,7 +189,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
Title = title, Title = title,
SubTitle = $"Use > to search within {subtitleFolderName}, " + SubTitle = $"Use > to search within {subtitleFolderName}, " +
$"* to search for file extensions or >* to combine both searches.", $"* to search for file extensions or >* to combine both searches.",
AutoCompleteText = GetPathWithActionKeyword(folderPath, ResultType.Folder), AutoCompleteText = GetPathWithActionKeyword(folderPath, ResultType.Folder, actionKeyword),
IcoPath = folderPath, IcoPath = folderPath,
Score = 500, Score = 500,
CopyText = folderPath, CopyText = folderPath,
@ -221,7 +220,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
SubTitle = Path.GetDirectoryName(filePath), SubTitle = Path.GetDirectoryName(filePath),
IcoPath = filePath, IcoPath = filePath,
Preview = preview, Preview = preview,
AutoCompleteText = GetPathWithActionKeyword(filePath, ResultType.File), AutoCompleteText = GetPathWithActionKeyword(filePath, ResultType.File, query.ActionKeyword),
TitleHighlightData = StringMatcher.FuzzySearch(query.Search, Path.GetFileName(filePath)).MatchData, TitleHighlightData = StringMatcher.FuzzySearch(query.Search, Path.GetFileName(filePath)).MatchData,
Score = score, Score = score,
CopyText = filePath, CopyText = filePath,

View file

@ -176,8 +176,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search
var retrievedDirectoryPath = FilesFolders.ReturnPreviousDirectoryIfIncompleteString(locationPath); var retrievedDirectoryPath = FilesFolders.ReturnPreviousDirectoryIfIncompleteString(locationPath);
results.Add(retrievedDirectoryPath.EndsWith(":\\") results.Add(retrievedDirectoryPath.EndsWith(":\\")
? ResultManager.CreateDriveSpaceDisplayResult(retrievedDirectoryPath, useIndexSearch) ? ResultManager.CreateDriveSpaceDisplayResult(retrievedDirectoryPath, query.ActionKeyword, useIndexSearch)
: ResultManager.CreateOpenCurrentFolderResult(retrievedDirectoryPath, useIndexSearch)); : ResultManager.CreateOpenCurrentFolderResult(retrievedDirectoryPath, query.ActionKeyword, useIndexSearch));
if (token.IsCancellationRequested) if (token.IsCancellationRequested)
return new List<Result>(); return new List<Result>();