From b10f7cb3a69bcf485c59034edfdc7cf6d4988555 Mon Sep 17 00:00:00 2001 From: Syrone Wong Date: Tue, 20 Sep 2016 08:43:34 +0800 Subject: [PATCH] Refine duplicate behaviour in ConfigForm - Use insert instead and move to newly inserted item instead of the last one after operation Signed-off-by: Syrone Wong --- shadowsocks-csharp/View/ConfigForm.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/shadowsocks-csharp/View/ConfigForm.cs b/shadowsocks-csharp/View/ConfigForm.cs index 91c4e0d2..b0228795 100755 --- a/shadowsocks-csharp/View/ConfigForm.cs +++ b/shadowsocks-csharp/View/ConfigForm.cs @@ -218,9 +218,10 @@ namespace Shadowsocks.View return; } Server currServer = _modifiedConfiguration.configs[_lastSelectedIndex]; - _modifiedConfiguration.configs.Add(currServer); + var currIndex = _modifiedConfiguration.configs.IndexOf( currServer ); + _modifiedConfiguration.configs.Insert(currIndex + 1, currServer); LoadConfiguration(_modifiedConfiguration); - ServersListBox.SelectedIndex = _modifiedConfiguration.configs.Count - 1; + ServersListBox.SelectedIndex = currIndex + 1; _lastSelectedIndex = ServersListBox.SelectedIndex; }