Skip to content

Commit 43b8cc5

Browse files
authored
Merge pull request #1750 from Flow-Launcher/fix_pluginindicator_search
Allow plugin name to be searchable by Plugin Indicator
2 parents a07df29 + ff00c67 commit 43b8cc5

File tree

4 files changed

+30
-27
lines changed

4 files changed

+30
-27
lines changed

.github/actions/spelling/expect.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,5 @@ TSource
5656
runas
5757
dpi
5858
popup
59-
ptr
59+
ptr
60+
pluginindicator

Plugins/Flow.Launcher.Plugin.PluginIndicator/Languages/en.xaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
33
xmlns:system="clr-namespace:System;assembly=mscorlib">
44

5+
<system:String x:Key="flowlauncher_plugin_pluginindicator_result_subtitle">Activate {0} plugin action keyword</system:String>
6+
57
<system:String x:Key="flowlauncher_plugin_pluginindicator_plugin_name">Plugin Indicator</system:String>
68
<system:String x:Key="flowlauncher_plugin_pluginindicator_plugin_description">Provides plugins action words suggestions</system:String>
7-
8-
</ResourceDictionary>
9+
10+
</ResourceDictionary>

Plugins/Flow.Launcher.Plugin.PluginIndicator/Main.cs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,28 @@ public class Main : IPlugin, IPluginI18n
1010

1111
public List<Result> Query(Query query)
1212
{
13-
// if query contains more than one word, eg. github tips
14-
// user has decided to type something else rather than wanting to see the available action keywords
15-
if (query.SearchTerms.Length > 1)
16-
return new List<Result>();
17-
18-
var results = from keyword in PluginManager.NonGlobalPlugins.Keys
19-
where keyword.StartsWith(query.Search)
20-
let metadata = PluginManager.NonGlobalPlugins[keyword].Metadata
21-
where !metadata.Disabled
22-
select new Result
23-
{
24-
Title = keyword,
25-
SubTitle = $"Activate {metadata.Name} plugin",
26-
Score = 100,
27-
IcoPath = metadata.IcoPath,
28-
AutoCompleteText = $"{keyword}{Plugin.Query.TermSeparator}",
29-
Action = c =>
30-
{
31-
context.API.ChangeQuery($"{keyword}{Plugin.Query.TermSeparator}");
32-
return false;
33-
}
34-
};
13+
var results =
14+
from keyword in PluginManager.NonGlobalPlugins.Keys
15+
let plugin = PluginManager.NonGlobalPlugins[keyword].Metadata
16+
let keywordSearchResult = context.API.FuzzySearch(query.Search, keyword)
17+
let searchResult = keywordSearchResult.IsSearchPrecisionScoreMet() ? keywordSearchResult : context.API.FuzzySearch(query.Search, plugin.Name)
18+
let score = searchResult.Score
19+
where (searchResult.IsSearchPrecisionScoreMet()
20+
|| string.IsNullOrEmpty(query.Search)) // To list all available action keywords
21+
&& !plugin.Disabled
22+
select new Result
23+
{
24+
Title = keyword,
25+
SubTitle = string.Format(context.API.GetTranslation("flowlauncher_plugin_pluginindicator_result_subtitle"), plugin.Name),
26+
Score = score,
27+
IcoPath = plugin.IcoPath,
28+
AutoCompleteText = $"{keyword}{Plugin.Query.TermSeparator}",
29+
Action = c =>
30+
{
31+
context.API.ChangeQuery($"{keyword}{Plugin.Query.TermSeparator}");
32+
return false;
33+
}
34+
};
3535
return results.ToList();
3636
}
3737

Plugins/Flow.Launcher.Plugin.PluginIndicator/plugin.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"ID": "6A122269676E40EB86EB543B945932B9",
33
"ActionKeyword": "*",
44
"Name": "Plugin Indicator",
5-
"Description": "Provide plugin actionword suggestion",
5+
"Description": "Provides plugin action keyword suggestions",
66
"Author": "qianlifeng",
7-
"Version": "2.0.0",
7+
"Version": "2.0.1",
88
"Language": "csharp",
99
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
1010
"ExecuteFileName": "Flow.Launcher.Plugin.PluginIndicator.dll",

0 commit comments

Comments
 (0)