From 174cf571110f888abe805eb5871584526180d063 Mon Sep 17 00:00:00 2001 From: Stzx Date: Wed, 4 Sep 2019 23:33:25 +0800 Subject: [PATCH] Fix accidental index invalidation Fixed an invalid index that was unexpectedly caused when the configuration was abandoned, resulting in an list box index exception. --- 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 814183b5..67edf735 100755 --- a/shadowsocks-csharp/View/ConfigForm.cs +++ b/shadowsocks-csharp/View/ConfigForm.cs @@ -1,6 +1,7 @@ -using System; +using System; using System.Drawing; using System.Windows.Forms; + using Shadowsocks.Controller; using Shadowsocks.Model; using Shadowsocks.Properties; @@ -157,7 +158,7 @@ namespace Shadowsocks.View LoadServerNameListToUI(_modifiedConfiguration); - _lastSelectedIndex = (ServersListBox.SelectedIndex = lastIndex); + _lastSelectedIndex = (ServersListBox.SelectedIndex = ( _lastSelectedIndex == ServersListBox.Items.Count ? lastIndex : lastIndex - 1)); ServersListBox.SelectedIndexChanged += ServersListBox_SelectedIndexChanged; return true;