Fix config selection

User wants to use that server after selected it in the ConfigForm. If user deletes
the server in use, we can't find its index, then the previous logic will revert to
index 0, which is not expected behaviour.

Since we handled 'ServersListBox.SelectedIndex' in various event handlers, we can
trust it all the time.

Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
This commit is contained in:
Syrone Wong
2016-09-04 08:04:56 +08:00
parent e364457b1b
commit 514bb02098
+4 -2
View File
@@ -230,7 +230,6 @@ namespace Shadowsocks.View
private void OKButton_Click(object sender, EventArgs e)
{
Server server = controller.GetCurrentServer();
if (!SaveOldSelectedServer())
{
return;
@@ -241,7 +240,10 @@ namespace Shadowsocks.View
return;
}
controller.SaveServers(_modifiedConfiguration.configs, _modifiedConfiguration.localPort);
controller.SelectServerIndex(_modifiedConfiguration.configs.IndexOf(server));
// SelectedIndex remains valid
// We handled this in event handlers, e.g. Add/DeleteButton, SelectedIndexChanged
// and move operations
controller.SelectServerIndex(ServersListBox.SelectedIndex);
this.Close();
}