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
26 changes: 20 additions & 6 deletions Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,29 @@ public static void Init(PluginInitContext context, Settings settings)
Settings = settings;
}

private static string GetPathWithActionKeyword(string path, ResultType type)
{
// one of it is enabled
var keyword = Settings.SearchActionKeywordEnabled ? Settings.SearchActionKeyword : Settings.PathSearchActionKeyword;

keyword = keyword == Query.GlobalPluginWildcardSign ? string.Empty : keyword + " ";

var formatted_path = path;

if (type == ResultType.Folder)
formatted_path = path.EndsWith(Constants.DirectorySeperator) ? path : path + Constants.DirectorySeperator;

return $"{keyword}{formatted_path}";
}

internal static Result CreateFolderResult(string title, string subtitle, string path, Query query, int score = 0, bool showIndexState = false, bool windowsIndexed = false)
{
return new Result
{
Title = title,
IcoPath = path,
SubTitle = subtitle,
AutoCompleteText = GetPathWithActionKeyword(path, ResultType.Folder),
TitleHighlightData = StringMatcher.FuzzySearch(query.Search, title).MatchData,
Action = c =>
{
Expand All @@ -43,13 +59,9 @@ internal static Result CreateFolderResult(string title, string subtitle, string
return false;
}
}
// one of it is enabled
var keyword = Settings.SearchActionKeywordEnabled ? Settings.SearchActionKeyword : Settings.PathSearchActionKeyword;

keyword = keyword == Query.GlobalPluginWildcardSign ? string.Empty : keyword + " ";

string changeTo = path.EndsWith(Constants.DirectorySeperator) ? path : path + Constants.DirectorySeperator;
Context.API.ChangeQuery($"{keyword}{changeTo}");
Context.API.ChangeQuery(GetPathWithActionKeyword(path, ResultType.Folder));

return false;
},
Score = score,
Expand Down Expand Up @@ -97,6 +109,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(retrievedDirectoryPath, ResultType.Folder),
IcoPath = retrievedDirectoryPath,
Score = 500,
Action = c =>
Expand All @@ -123,6 +136,7 @@ internal static Result CreateFileResult(string filePath, Query query, int score
Title = Path.GetFileName(filePath),
SubTitle = filePath,
IcoPath = filePath,
AutoCompleteText = GetPathWithActionKeyword(filePath, ResultType.File),
TitleHighlightData = StringMatcher.FuzzySearch(query.Search, Path.GetFileName(filePath)).MatchData,
Score = score,
Action = c =>
Expand Down
2 changes: 1 addition & 1 deletion Plugins/Flow.Launcher.Plugin.Explorer/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"Name": "Explorer",
"Description": "Search and manage files and folders. Explorer utilises Windows Index Search",
"Author": "Jeremy Wu",
"Version": "1.10.1",
"Version": "1.11.0",
"Language": "csharp",
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
"ExecuteFileName": "Flow.Launcher.Plugin.Explorer.dll",
Expand Down