mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Fix ArgumentOutOfRangeException in WebSearch Plugin (#4041)
This commit is contained in:
parent
5ae159de5b
commit
b297f3d3a3
3 changed files with 24 additions and 7 deletions
|
|
@ -89,9 +89,12 @@ public partial class SettingsPaneHotkeyViewModel : BaseModel
|
|||
if (window.ShowDialog() is not true) return;
|
||||
|
||||
var index = Settings.CustomPluginHotkeys.IndexOf(settingItem);
|
||||
Settings.CustomPluginHotkeys[index] = new CustomPluginHotkey(window.Hotkey, window.ActionKeyword);
|
||||
HotKeyMapper.RemoveHotkey(settingItem.Hotkey); // remove origin hotkey
|
||||
HotKeyMapper.SetCustomQueryHotkey(Settings.CustomPluginHotkeys[index]); // set new hotkey
|
||||
if (index >= 0 && index < Settings.CustomPluginHotkeys.Count)
|
||||
{
|
||||
Settings.CustomPluginHotkeys[index] = new CustomPluginHotkey(window.Hotkey, window.ActionKeyword);
|
||||
HotKeyMapper.RemoveHotkey(settingItem.Hotkey); // remove origin hotkey
|
||||
HotKeyMapper.SetCustomQueryHotkey(Settings.CustomPluginHotkeys[index]); // set new hotkey
|
||||
}
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
|
|
@ -150,7 +153,10 @@ public partial class SettingsPaneHotkeyViewModel : BaseModel
|
|||
if (window.ShowDialog() is not true) return;
|
||||
|
||||
var index = Settings.CustomShortcuts.IndexOf(settingItem);
|
||||
Settings.CustomShortcuts[index] = new CustomShortcutModel(window.Key, window.Value);
|
||||
if (index >= 0 && index < Settings.CustomShortcuts.Count)
|
||||
{
|
||||
Settings.CustomShortcuts[index] = new CustomShortcutModel(window.Key, window.Value);
|
||||
}
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@
|
|||
<system:String x:Key="flowlauncher_plugin_websearch_input_url">Please enter a URL</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_websearch_action_keyword_exist">Action keyword already exists, please enter a different one</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_websearch_succeed">Success</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_websearch_edit_failed">Failed to update search source. The item may have been removed.</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_websearch_iconpath_hint">Hint: You do not need to place custom images in this directory, if Flow's version is updated they will be lost. Flow will automatically copy any images outside of this directory across to WebSearch's custom image location.</system:String>
|
||||
|
||||
<system:String x:Key="flowlauncher_plugin_websearch_plugin_name">Web Searches</system:String>
|
||||
|
|
|
|||
|
|
@ -108,9 +108,19 @@ namespace Flow.Launcher.Plugin.WebSearch
|
|||
_context.API.AddActionKeyword(id, newKeyword);
|
||||
|
||||
var index = _searchSources.IndexOf(_oldSearchSource);
|
||||
_searchSources[index] = _searchSource;
|
||||
|
||||
Close();
|
||||
|
||||
// Only update if we found the item in the collection
|
||||
if (index >= 0 && index < _searchSources.Count)
|
||||
{
|
||||
_searchSources[index] = _searchSource;
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
var warning = _api.GetTranslation("flowlauncher_plugin_websearch_edit_failed");
|
||||
_context.API.ShowMsgBox(warning);
|
||||
Close();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue