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.
This commit is contained in:
Ioannis G 2023-06-12 15:49:33 +03:00
parent 1b68d09d51
commit e6baa88002
No known key found for this signature in database
GPG key ID: EAC0E4E5E36AC49E

View file

@ -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;
};