From 3df85772b016726a7cc62f3515eb499650b5c7b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E5=AE=87=E8=88=AA?= Date: Sat, 15 Apr 2017 09:10:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8D=E8=BF=9E=E7=BB=AD?= =?UTF-8?q?=E5=A4=9A=E9=80=89=E5=88=A0=E9=99=A4=E9=94=99=E8=AF=AF=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ShadowsocksX-NG/PreferencesWindowController.swift | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ShadowsocksX-NG/PreferencesWindowController.swift b/ShadowsocksX-NG/PreferencesWindowController.swift index 5957831..a4f3082 100644 --- a/ShadowsocksX-NG/PreferencesWindowController.swift +++ b/ShadowsocksX-NG/PreferencesWindowController.swift @@ -131,12 +131,14 @@ class PreferencesWindowController: NSWindowController @IBAction func removeProfile(_ sender: NSButton) { let index = Int(profilesTableView.selectedRowIndexes.first!) + var deleteCount = 0 if index >= 0 { profilesTableView.beginUpdates() - for (_, _) in profilesTableView.selectedRowIndexes.enumerated() { + for (_, toDeleteIndex) in profilesTableView.selectedRowIndexes.enumerated() { print(profileMgr.profiles.count) - profileMgr.profiles.remove(at: index) - profilesTableView.removeRows(at: IndexSet(integer: index), withAnimation: .effectFade) + profileMgr.profiles.remove(at: toDeleteIndex - deleteCount) + profilesTableView.removeRows(at: IndexSet(integer: toDeleteIndex - deleteCount), withAnimation: .effectFade) + deleteCount += 1 } profilesTableView.endUpdates() }