Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,15 @@ public static void Init(PluginInitContext context, 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
var keyword = Settings.SearchActionKeywordEnabled ? Settings.SearchActionKeyword : Settings.PathSearchActionKeyword;

keyword = keyword == Query.GlobalPluginWildcardSign ? string.Empty : keyword + " ";
// Query.ActionKeyword is string.Empty when Global Action Keyword ('*') is used
var keyword = actionKeyword != string.Empty ? actionKeyword + " " : string.Empty;

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;

return $"{keyword}{formatted_path}";
Expand All @@ -55,7 +54,7 @@ internal static Result CreateFolderResult(string title, string subtitle, string
Title = title,
IcoPath = path,
SubTitle = Path.GetDirectoryName(path),
AutoCompleteText = GetPathWithActionKeyword(path, ResultType.Folder),
AutoCompleteText = GetPathWithActionKeyword(path, ResultType.Folder, query.ActionKeyword),
TitleHighlightData = StringMatcher.FuzzySearch(query.Search, title).MatchData,
CopyText = path,
Action = c =>
Expand All @@ -74,7 +73,7 @@ internal static Result CreateFolderResult(string title, string subtitle, string
}
}

Context.API.ChangeQuery(GetPathWithActionKeyword(path, ResultType.Folder));
Context.API.ChangeQuery(GetPathWithActionKeyword(path, ResultType.Folder, query.ActionKeyword));

return false;
},
Expand All @@ -90,7 +89,7 @@ internal static Result CreateFolderResult(string title, string subtitle, string
};
}

internal static Result CreateDriveSpaceDisplayResult(string path, bool windowsIndexed = false)
internal static Result CreateDriveSpaceDisplayResult(string path, string actionKeyword, bool windowsIndexed = false)
{
var progressBarColor = "#26a0da";
var title = string.Empty; // hide title when use progress bar,
Expand All @@ -109,7 +108,7 @@ internal static Result CreateDriveSpaceDisplayResult(string path, bool windowsIn
{
Title = title,
SubTitle = subtitle,
AutoCompleteText = GetPathWithActionKeyword(path, ResultType.Folder),
AutoCompleteText = GetPathWithActionKeyword(path, ResultType.Folder, actionKeyword),
IcoPath = path,
Score = 500,
ProgressBar = progressValue,
Expand Down Expand Up @@ -166,7 +165,7 @@ private static string ToReadableSize(long pDrvSize, int pi)
return returnStr;
}

internal static Result CreateOpenCurrentFolderResult(string path, bool windowsIndexed = false)
internal static Result CreateOpenCurrentFolderResult(string path, string actionKeyword, bool windowsIndexed = false)
{
var folderName = path.TrimEnd(Constants.DirectorySeperator).Split(new[]
{
Expand All @@ -186,7 +185,7 @@ internal static Result CreateOpenCurrentFolderResult(string path, bool windowsIn
Title = title,
SubTitle = $"Use > to search within {subtitleFolderName}, " +
$"* to search for file extensions or >* to combine both searches.",
AutoCompleteText = GetPathWithActionKeyword(path, ResultType.Folder),
AutoCompleteText = GetPathWithActionKeyword(path, ResultType.Folder, actionKeyword),
IcoPath = path,
Score = 500,
CopyText = path,
Expand Down Expand Up @@ -217,7 +216,7 @@ internal static Result CreateFileResult(string filePath, Query query, int score
SubTitle = Path.GetDirectoryName(filePath),
IcoPath = filePath,
Preview = preview,
AutoCompleteText = GetPathWithActionKeyword(filePath, ResultType.File),
AutoCompleteText = GetPathWithActionKeyword(filePath, ResultType.File, query.ActionKeyword),
TitleHighlightData = StringMatcher.FuzzySearch(query.Search, Path.GetFileName(filePath)).MatchData,
Score = score,
CopyText = filePath,
Expand Down
4 changes: 2 additions & 2 deletions Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ private async Task<List<Result>> PathSearchAsync(Query query, CancellationToken
var retrievedDirectoryPath = FilesFolders.ReturnPreviousDirectoryIfIncompleteString(locationPath);

results.Add(retrievedDirectoryPath.EndsWith(":\\")
? ResultManager.CreateDriveSpaceDisplayResult(retrievedDirectoryPath, useIndexSearch)
: ResultManager.CreateOpenCurrentFolderResult(retrievedDirectoryPath, useIndexSearch));
? ResultManager.CreateDriveSpaceDisplayResult(retrievedDirectoryPath, query.ActionKeyword, useIndexSearch)
: ResultManager.CreateOpenCurrentFolderResult(retrievedDirectoryPath, query.ActionKeyword, useIndexSearch));

if (token.IsCancellationRequested)
return new List<Result>();
Expand Down