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
17 changes: 14 additions & 3 deletions Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public class Main : IAsyncPlugin, ISettingProvider, IPluginI18n, ISavable, IResu
internal static string DefaultImagesDirectory;
internal static string CustomImagesDirectory;

private readonly int scoreStandard = 50;

private readonly int scoreSuggestions = 48;

private readonly string SearchSourceGlobalPluginWildCardSign = "*";

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

//Action Keyword match apear on top
var score = searchSource.ActionKeyword == SearchSourceGlobalPluginWildCardSign ? scoreStandard : scoreStandard + 1;

if (string.IsNullOrEmpty(keyword))
{
var result = new Result
{
Title = subtitle,
SubTitle = string.Empty,
IcoPath = searchSource.IconPath
IcoPath = searchSource.IconPath,
Score = score
};
results.Add(result);
}
Expand All @@ -65,9 +73,9 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
{
Title = title,
SubTitle = subtitle,
Score = 6,
IcoPath = searchSource.IconPath,
ActionKeywordAssigned = searchSource.ActionKeyword == SearchSourceGlobalPluginWildCardSign ? string.Empty : searchSource.ActionKeyword,
Score = score,
Action = c =>
{
if (_settings.OpenInNewBrowser)
Expand Down Expand Up @@ -123,6 +131,9 @@ private async Task<IEnumerable<Result>> SuggestionsAsync(string keyword, string
var source = _settings.SelectedSuggestion;
if (source != null)
{
//Suggestions appear below actual result, and appear above global action keyword match if non-global;
var score = searchSource.ActionKeyword == SearchSourceGlobalPluginWildCardSign ? scoreSuggestions : scoreSuggestions + 1;

var suggestions = await source.Suggestions(keyword, token).ConfigureAwait(false);

token.ThrowIfCancellationRequested();
Expand All @@ -131,7 +142,7 @@ private async Task<IEnumerable<Result>> SuggestionsAsync(string keyword, string
{
Title = o,
SubTitle = subtitle,
Score = 5,
Score = score,
IcoPath = searchSource.IconPath,
ActionKeywordAssigned = searchSource.ActionKeyword == SearchSourceGlobalPluginWildCardSign ? string.Empty : searchSource.ActionKeyword,
Action = c =>
Expand Down
2 changes: 1 addition & 1 deletion Plugins/Flow.Launcher.Plugin.WebSearch/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public Settings()
new SearchSource
{
Title = "Google",
ActionKeyword = "g",
ActionKeyword = "*",
Icon = "google.png",
Url = "https://www.google.com/search?q={q}",
Enabled = true
Expand Down
4 changes: 2 additions & 2 deletions Plugins/Flow.Launcher.Plugin.WebSearch/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"ID": "565B73353DBF4806919830B9202EE3BF",
"ActionKeywords": [
"g",
"*",
"wiki",
"findicon",
"facebook",
Expand All @@ -25,7 +25,7 @@
"Name": "Web Searches",
"Description": "Provide the web search ability",
"Author": "qianlifeng",
"Version": "1.3.4",
"Version": "1.3.5",
"Language": "csharp",
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
"ExecuteFileName": "Flow.Launcher.Plugin.WebSearch.dll",
Expand Down
2 changes: 1 addition & 1 deletion Plugins/Flow.Launcher.Plugin.WebSearch/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"WebSearches": [
{
"Title": "Google",
"ActionKeyword": "g",
"ActionKeyword": "*",
"IconPath": "Images\\google.png",
"Url": "https://www.google.com/search?q={q}",
"Enabled": true
Expand Down