Skip to content

Commit d73dedc

Browse files
committed
Revert namespace style
1 parent 979f75e commit d73dedc

File tree

1 file changed

+63
-62
lines changed
  • Plugins/Flow.Launcher.Plugin.PluginIndicator

1 file changed

+63
-62
lines changed
Lines changed: 63 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,84 @@
11
using System.Collections.Generic;
22
using System.Linq;
33

4-
namespace Flow.Launcher.Plugin.PluginIndicator;
5-
6-
public class Main : IPlugin, IPluginI18n, IHomeQuery
4+
namespace Flow.Launcher.Plugin.PluginIndicator
75
{
8-
internal static PluginInitContext Context { get; private set; }
9-
10-
public void Init(PluginInitContext context)
6+
public class Main : IPlugin, IPluginI18n, IHomeQuery
117
{
12-
Context = context;
13-
}
8+
internal static PluginInitContext Context { get; private set; }
149

15-
public List<Result> Query(Query query)
16-
{
17-
return QueryResults(query);
18-
}
10+
public void Init(PluginInitContext context)
11+
{
12+
Context = context;
13+
}
1914

20-
private static List<Result> QueryResults(Query query = null)
21-
{
22-
var nonGlobalPlugins = GetNonGlobalPlugins();
23-
var querySearch = query?.Search ?? string.Empty;
15+
public List<Result> Query(Query query)
16+
{
17+
return QueryResults(query);
18+
}
2419

25-
var results =
26-
from keyword in nonGlobalPlugins.Keys
27-
let plugin = nonGlobalPlugins[keyword].Metadata
28-
let keywordSearchResult = Context.API.FuzzySearch(querySearch, keyword)
29-
let searchResult = keywordSearchResult.IsSearchPrecisionScoreMet() ? keywordSearchResult : Context.API.FuzzySearch(querySearch, plugin.Name)
30-
let score = searchResult.Score
31-
where (searchResult.IsSearchPrecisionScoreMet()
32-
|| string.IsNullOrEmpty(querySearch)) // To list all available action keywords
33-
&& !plugin.Disabled
34-
select new Result
35-
{
36-
Title = keyword,
37-
SubTitle = Localize.flowlauncher_plugin_pluginindicator_result_subtitle(plugin.Name),
38-
Score = score,
39-
IcoPath = plugin.IcoPath,
40-
AutoCompleteText = $"{keyword}{Plugin.Query.TermSeparator}",
41-
Action = c =>
20+
private static List<Result> QueryResults(Query query = null)
21+
{
22+
var nonGlobalPlugins = GetNonGlobalPlugins();
23+
var querySearch = query?.Search ?? string.Empty;
24+
25+
var results =
26+
from keyword in nonGlobalPlugins.Keys
27+
let plugin = nonGlobalPlugins[keyword].Metadata
28+
let keywordSearchResult = Context.API.FuzzySearch(querySearch, keyword)
29+
let searchResult = keywordSearchResult.IsSearchPrecisionScoreMet() ? keywordSearchResult : Context.API.FuzzySearch(querySearch, plugin.Name)
30+
let score = searchResult.Score
31+
where (searchResult.IsSearchPrecisionScoreMet()
32+
|| string.IsNullOrEmpty(querySearch)) // To list all available action keywords
33+
&& !plugin.Disabled
34+
select new Result
4235
{
43-
Context.API.ChangeQuery($"{keyword}{Plugin.Query.TermSeparator}");
44-
return false;
45-
}
46-
};
47-
return [.. results];
48-
}
36+
Title = keyword,
37+
SubTitle = Localize.flowlauncher_plugin_pluginindicator_result_subtitle(plugin.Name),
38+
Score = score,
39+
IcoPath = plugin.IcoPath,
40+
AutoCompleteText = $"{keyword}{Plugin.Query.TermSeparator}",
41+
Action = c =>
42+
{
43+
Context.API.ChangeQuery($"{keyword}{Plugin.Query.TermSeparator}");
44+
return false;
45+
}
46+
};
47+
return [.. results];
48+
}
4949

50-
private static Dictionary<string, PluginPair> GetNonGlobalPlugins()
51-
{
52-
var nonGlobalPlugins = new Dictionary<string, PluginPair>();
53-
foreach (var plugin in Context.API.GetAllPlugins())
50+
private static Dictionary<string, PluginPair> GetNonGlobalPlugins()
5451
{
55-
foreach (var actionKeyword in plugin.Metadata.ActionKeywords)
52+
var nonGlobalPlugins = new Dictionary<string, PluginPair>();
53+
foreach (var plugin in Context.API.GetAllPlugins())
5654
{
57-
// Skip global keywords
58-
if (actionKeyword == Plugin.Query.GlobalPluginWildcardSign) continue;
55+
foreach (var actionKeyword in plugin.Metadata.ActionKeywords)
56+
{
57+
// Skip global keywords
58+
if (actionKeyword == Plugin.Query.GlobalPluginWildcardSign) continue;
5959

60-
// Skip dulpicated keywords
61-
if (nonGlobalPlugins.ContainsKey(actionKeyword)) continue;
60+
// Skip dulpicated keywords
61+
if (nonGlobalPlugins.ContainsKey(actionKeyword)) continue;
6262

63-
nonGlobalPlugins.Add(actionKeyword, plugin);
63+
nonGlobalPlugins.Add(actionKeyword, plugin);
64+
}
6465
}
66+
return nonGlobalPlugins;
6567
}
66-
return nonGlobalPlugins;
67-
}
6868

69-
public string GetTranslatedPluginTitle()
70-
{
71-
return Localize.flowlauncher_plugin_pluginindicator_plugin_name();
72-
}
69+
public string GetTranslatedPluginTitle()
70+
{
71+
return Localize.flowlauncher_plugin_pluginindicator_plugin_name();
72+
}
7373

74-
public string GetTranslatedPluginDescription()
75-
{
76-
return Localize.flowlauncher_plugin_pluginindicator_plugin_description();
77-
}
74+
public string GetTranslatedPluginDescription()
75+
{
76+
return Localize.flowlauncher_plugin_pluginindicator_plugin_description();
77+
}
7878

79-
public List<Result> HomeQuery()
80-
{
81-
return QueryResults();
79+
public List<Result> HomeQuery()
80+
{
81+
return QueryResults();
82+
}
8283
}
8384
}

0 commit comments

Comments
 (0)