Skip to content

Commit

Permalink
refactor: search functionality and update tooltips
Browse files Browse the repository at this point in the history
  • Loading branch information
Daydreamer-riri committed Mar 29, 2024
1 parent ff32ce2 commit 9dc951d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions Community.PowerToys.Run.Plugin.WebSearchShortcut/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public List<Result> Query(Query query, bool delayedExecution)
{
ResetSuggestionsCache();
}
else if (item != null && !string.IsNullOrEmpty(item.SuggestionProvider) && item.IsDefault != true)
else if (item != null && !string.IsNullOrEmpty(item.SuggestionProvider))
{
results = ProcessItem(item, tokens, query, results);
}
Expand Down Expand Up @@ -267,6 +267,7 @@ private Result GetResultForSelect(Item item, string args, Query query)
IcoPath = item.IconPath ?? IconPath["Search"],
Title = item.Name,
SubTitle = $"Search using {item.Name}",
Score = 100,
Action = _ =>
{
var newQuery = string.IsNullOrWhiteSpace(query.ActionKeyword)
Expand All @@ -292,7 +293,7 @@ private static Result GetResultForSearch(Item item, string search, Query query,
ProgramArguments = arguments,
Action = _ => OpenInBrowser(arguments),
Score = isDefault ? 1001 : 1000,
ToolTipData = new ToolTipData("Open", $"{arguments}"),
ToolTipData = new ToolTipData("Open (Enter)", $"{arguments}"),
ContextData = item,
};
}
Expand Down
4 changes: 2 additions & 2 deletions Community.PowerToys.Run.Plugin.WebSearchShortcut/Storage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public WebSearchShortcutStorage(WebSearchShortcutSettings settings)

/// <inheritdoc/>
public IReadOnlyCollection<Item> GetRecords(string query) => Data.Values
.Where(x => x.IsDefault != true)
// .Where(x => x.IsDefault != true)
.Where(x =>
(x.Keyword?.Contains(query, StringComparison.InvariantCultureIgnoreCase) ?? false)
|| (x.Name?.Contains(query, StringComparison.InvariantCultureIgnoreCase) ?? false)
Expand All @@ -96,7 +96,7 @@ public IReadOnlyCollection<Item> GetRecords(string query) => Data.Values
{
key = key.Trim();
return Data.Values
.Where(x => x.IsDefault != true)
// .Where(x => x.IsDefault != true)
.FirstOrDefault(x =>
(x.Name?.Equals(key, StringComparison.InvariantCultureIgnoreCase) ?? false)
|| (x.Keyword?.Equals(key, StringComparison.InvariantCultureIgnoreCase) ?? false)
Expand Down

0 comments on commit 9dc951d

Please sign in to comment.