diff --git a/Flow.Launcher/CustomShortcutSetting.xaml.cs b/Flow.Launcher/CustomShortcutSetting.xaml.cs index e180f6570..f4644a267 100644 --- a/Flow.Launcher/CustomShortcutSetting.xaml.cs +++ b/Flow.Launcher/CustomShortcutSetting.xaml.cs @@ -43,12 +43,14 @@ namespace Flow.Launcher App.API.ShowMsgBox(App.API.GetTranslation("emptyShortcut")); return; } + // Check if key is modified or adding a new one if (((update && originalKey != Key) || !update) && _hotkeyVm.DoesShortcutExist(Key)) { App.API.ShowMsgBox(App.API.GetTranslation("duplicateShortcut")); return; } + DialogResult = !update || originalKey != Key || originalValue != Value; Close(); } diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index 55bbed7e0..7c94030ef 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -446,6 +446,7 @@ Shortcut already exists, please enter a new Shortcut or edit the existing one. Shortcut and/or its expansion is empty. + Shortcut is invalid Save diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs index 8a58bb4dd..bec170ec8 100644 --- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs +++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs @@ -107,10 +107,18 @@ public partial class SettingsPaneHotkeyViewModel : BaseModel return; } - var window = new CustomShortcutSetting(item.Key, item.Value, this); + var settingItem = Settings.CustomShortcuts.FirstOrDefault(o => + o.Key == item.Key && o.Value == item.Value); + if (settingItem == null) + { + App.API.ShowMsgBox(App.API.GetTranslation("invalidShortcut")); + return; + } + + var window = new CustomShortcutSetting(settingItem.Key, settingItem.Value, this); if (window.ShowDialog() is not true) return; - var index = Settings.CustomShortcuts.IndexOf(item); + var index = Settings.CustomShortcuts.IndexOf(settingItem); Settings.CustomShortcuts[index] = new CustomShortcutModel(window.Key, window.Value); }