Skip to content

Commit b10f7cb

Browse files
committed
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 <[email protected]>
1 parent 78957e2 commit b10f7cb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

shadowsocks-csharp/View/ConfigForm.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,10 @@ private void DuplicateButton_Click( object sender, EventArgs e )
218218
return;
219219
}
220220
Server currServer = _modifiedConfiguration.configs[_lastSelectedIndex];
221-
_modifiedConfiguration.configs.Add(currServer);
221+
var currIndex = _modifiedConfiguration.configs.IndexOf( currServer );
222+
_modifiedConfiguration.configs.Insert(currIndex + 1, currServer);
222223
LoadConfiguration(_modifiedConfiguration);
223-
ServersListBox.SelectedIndex = _modifiedConfiguration.configs.Count - 1;
224+
ServersListBox.SelectedIndex = currIndex + 1;
224225
_lastSelectedIndex = ServersListBox.SelectedIndex;
225226
}
226227

0 commit comments

Comments
 (0)