From e6baa88002290203d099772e33a2d2f453328146 Mon Sep 17 00:00:00 2001 From: Ioannis G Date: Mon, 12 Jun 2023 15:49:33 +0300 Subject: [PATCH] decouple Shell from the ComboBox SelectedIndex enables us to add new `Shell` options without messing with the user's saved settings, while keeping the `RunCommand` option last. --- .../ShellSetting.xaml.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Shell/ShellSetting.xaml.cs b/Plugins/Flow.Launcher.Plugin.Shell/ShellSetting.xaml.cs index 749e9ec80..f4e8229b7 100644 --- a/Plugins/Flow.Launcher.Plugin.Shell/ShellSetting.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Shell/ShellSetting.xaml.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Windows; using System.Windows.Controls; @@ -68,10 +68,21 @@ namespace Flow.Launcher.Plugin.Shell _settings.ReplaceWinR = false; }; - ShellComboBox.SelectedIndex = (int) _settings.Shell; + ShellComboBox.SelectedIndex = _settings.Shell switch + { + Shell.Cmd => 0, + Shell.Powershell => 1, + _ => ShellComboBox.Items.Count - 1 + }; + ShellComboBox.SelectionChanged += (o, e) => { - _settings.Shell = (Shell) ShellComboBox.SelectedIndex; + _settings.Shell = ShellComboBox.SelectedIndex switch + { + 0 => Shell.Cmd, + 1 => Shell.Powershell, + _ => Shell.RunCommand + }; LeaveShellOpen.IsEnabled = _settings.Shell != Shell.RunCommand; };