diff --git a/shadowsocks-csharp/View/ConfigForm.cs b/shadowsocks-csharp/View/ConfigForm.cs index 6bf861aa..f2a190da 100755 --- a/shadowsocks-csharp/View/ConfigForm.cs +++ b/shadowsocks-csharp/View/ConfigForm.cs @@ -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(); }