Merge pull request #1750 from Flow-Launcher/fix_pluginindicator_search

Allow plugin name to be searchable by Plugin Indicator
This commit is contained in:
Jeremy Wu 2023-01-01 15:21:13 +09:30 committed by GitHub
commit 43b8cc5a7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 27 deletions

View file

@ -56,4 +56,5 @@ TSource
runas
dpi
popup
ptr
ptr
pluginindicator

View file

@ -2,7 +2,9 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="flowlauncher_plugin_pluginindicator_result_subtitle">Activate {0} plugin action keyword</system:String>
<system:String x:Key="flowlauncher_plugin_pluginindicator_plugin_name">Plugin Indicator</system:String>
<system:String x:Key="flowlauncher_plugin_pluginindicator_plugin_description">Provides plugins action words suggestions</system:String>
</ResourceDictionary>
</ResourceDictionary>

View file

@ -10,28 +10,28 @@ namespace Flow.Launcher.Plugin.PluginIndicator
public List<Result> Query(Query query)
{
// if query contains more than one word, eg. github tips
// user has decided to type something else rather than wanting to see the available action keywords
if (query.SearchTerms.Length > 1)
return new List<Result>();
var results = from keyword in PluginManager.NonGlobalPlugins.Keys
where keyword.StartsWith(query.Search)
let metadata = PluginManager.NonGlobalPlugins[keyword].Metadata
where !metadata.Disabled
select new Result
{
Title = keyword,
SubTitle = $"Activate {metadata.Name} plugin",
Score = 100,
IcoPath = metadata.IcoPath,
AutoCompleteText = $"{keyword}{Plugin.Query.TermSeparator}",
Action = c =>
{
context.API.ChangeQuery($"{keyword}{Plugin.Query.TermSeparator}");
return false;
}
};
var results =
from keyword in PluginManager.NonGlobalPlugins.Keys
let plugin = PluginManager.NonGlobalPlugins[keyword].Metadata
let keywordSearchResult = context.API.FuzzySearch(query.Search, keyword)
let searchResult = keywordSearchResult.IsSearchPrecisionScoreMet() ? keywordSearchResult : context.API.FuzzySearch(query.Search, plugin.Name)
let score = searchResult.Score
where (searchResult.IsSearchPrecisionScoreMet()
|| string.IsNullOrEmpty(query.Search)) // To list all available action keywords
&& !plugin.Disabled
select new Result
{
Title = keyword,
SubTitle = string.Format(context.API.GetTranslation("flowlauncher_plugin_pluginindicator_result_subtitle"), plugin.Name),
Score = score,
IcoPath = plugin.IcoPath,
AutoCompleteText = $"{keyword}{Plugin.Query.TermSeparator}",
Action = c =>
{
context.API.ChangeQuery($"{keyword}{Plugin.Query.TermSeparator}");
return false;
}
};
return results.ToList();
}

View file

@ -2,9 +2,9 @@
"ID": "6A122269676E40EB86EB543B945932B9",
"ActionKeyword": "*",
"Name": "Plugin Indicator",
"Description": "Provide plugin actionword suggestion",
"Description": "Provides plugin action keyword suggestions",
"Author": "qianlifeng",
"Version": "2.0.0",
"Version": "2.0.1",
"Language": "csharp",
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
"ExecuteFileName": "Flow.Launcher.Plugin.PluginIndicator.dll",