-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathSearchWebCommand.cs
More file actions
36 lines (29 loc) · 1.25 KB
/
SearchWebCommand.cs
File metadata and controls
36 lines (29 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using Microsoft.CommandPalette.Extensions.Toolkit;
using WebSearchShortcut.Browsers;
using WebSearchShortcut.History;
namespace WebSearchShortcut.Commands;
internal sealed partial class SearchWebCommand : InvokableCommand
{
private readonly string _query;
private readonly WebSearchShortcutDataEntry _shortcut;
private readonly BrowserExecutionInfo _browserInfo;
// private readonly SettingsManager _settingsManager;
public SearchWebCommand(WebSearchShortcutDataEntry shortcut, string query)
{
Name = $"[UNBOUND] {nameof(SearchWebCommand)}.{nameof(Name)} required - shortcut='{shortcut.Name}', query='{query}'";
_query = query;
_shortcut = shortcut;
_browserInfo = new BrowserExecutionInfo(shortcut);
}
public override CommandResult Invoke()
{
if (!ShellHelpers.OpenCommandInShell(_browserInfo.Path, _browserInfo.ArgumentsPattern, WebSearchShortcutDataEntry.GetSearchUrl(_shortcut, _query)))
{
// TODO GH# 138 --> actually display feedback from the extension somewhere.
return CommandResult.KeepOpen();
}
if (_shortcut.RecordHistory ?? true)
HistoryService.Add(_shortcut.Name, _query);
return CommandResult.Dismiss();
}
}