Skip to content

Commit f927702

Browse files
authored
Merge pull request #372 from Flow-Launcher/change_websearch_default
Change WebSearch default to global
2 parents d65669c + ab8a850 commit f927702

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ public class Main : IAsyncPlugin, ISettingProvider, IPluginI18n, ISavable, IResu
2525
internal static string DefaultImagesDirectory;
2626
internal static string CustomImagesDirectory;
2727

28+
private readonly int scoreStandard = 50;
29+
30+
private readonly int scoreSuggestions = 48;
31+
2832
private readonly string SearchSourceGlobalPluginWildCardSign = "*";
2933

3034
public void Save()
@@ -49,13 +53,17 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
4953
var title = keyword;
5054
string subtitle = _context.API.GetTranslation("flowlauncher_plugin_websearch_search") + " " + searchSource.Title;
5155

56+
//Action Keyword match apear on top
57+
var score = searchSource.ActionKeyword == SearchSourceGlobalPluginWildCardSign ? scoreStandard : scoreStandard + 1;
58+
5259
if (string.IsNullOrEmpty(keyword))
5360
{
5461
var result = new Result
5562
{
5663
Title = subtitle,
5764
SubTitle = string.Empty,
58-
IcoPath = searchSource.IconPath
65+
IcoPath = searchSource.IconPath,
66+
Score = score
5967
};
6068
results.Add(result);
6169
}
@@ -65,9 +73,9 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
6573
{
6674
Title = title,
6775
SubTitle = subtitle,
68-
Score = 6,
6976
IcoPath = searchSource.IconPath,
7077
ActionKeywordAssigned = searchSource.ActionKeyword == SearchSourceGlobalPluginWildCardSign ? string.Empty : searchSource.ActionKeyword,
78+
Score = score,
7179
Action = c =>
7280
{
7381
if (_settings.OpenInNewBrowser)
@@ -123,6 +131,9 @@ private async Task<IEnumerable<Result>> SuggestionsAsync(string keyword, string
123131
var source = _settings.SelectedSuggestion;
124132
if (source != null)
125133
{
134+
//Suggestions appear below actual result, and appear above global action keyword match if non-global;
135+
var score = searchSource.ActionKeyword == SearchSourceGlobalPluginWildCardSign ? scoreSuggestions : scoreSuggestions + 1;
136+
126137
var suggestions = await source.Suggestions(keyword, token).ConfigureAwait(false);
127138

128139
token.ThrowIfCancellationRequested();
@@ -131,7 +142,7 @@ private async Task<IEnumerable<Result>> SuggestionsAsync(string keyword, string
131142
{
132143
Title = o,
133144
SubTitle = subtitle,
134-
Score = 5,
145+
Score = score,
135146
IcoPath = searchSource.IconPath,
136147
ActionKeywordAssigned = searchSource.ActionKeyword == SearchSourceGlobalPluginWildCardSign ? string.Empty : searchSource.ActionKeyword,
137148
Action = c =>

Plugins/Flow.Launcher.Plugin.WebSearch/Settings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public Settings()
2121
new SearchSource
2222
{
2323
Title = "Google",
24-
ActionKeyword = "g",
24+
ActionKeyword = "*",
2525
Icon = "google.png",
2626
Url = "https://www.google.com/search?q={q}",
2727
Enabled = true

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"ID": "565B73353DBF4806919830B9202EE3BF",
33
"ActionKeywords": [
4-
"g",
4+
"*",
55
"wiki",
66
"findicon",
77
"facebook",
@@ -25,7 +25,7 @@
2525
"Name": "Web Searches",
2626
"Description": "Provide the web search ability",
2727
"Author": "qianlifeng",
28-
"Version": "1.3.4",
28+
"Version": "1.3.5",
2929
"Language": "csharp",
3030
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
3131
"ExecuteFileName": "Flow.Launcher.Plugin.WebSearch.dll",

Plugins/Flow.Launcher.Plugin.WebSearch/setting.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"WebSearches": [
33
{
44
"Title": "Google",
5-
"ActionKeyword": "g",
5+
"ActionKeyword": "*",
66
"IconPath": "Images\\google.png",
77
"Url": "https://www.google.com/search?q={q}",
88
"Enabled": true

0 commit comments

Comments
 (0)