From efd0c767631746219875d6cb4a0eddeec0ea5d9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E5=AE=87=E8=88=AA?= Date: Mon, 24 Apr 2017 17:24:11 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"=E5=AE=9E=E7=8E=B0=E5=9C=A8=E5=A4=9A?= =?UTF-8?q?=E9=80=89=E7=8A=B6=E6=80=81=E4=B8=8B=E7=9A=84=E5=A4=9A=E4=B8=AA?= =?UTF-8?q?profile=E5=A4=8D=E5=88=B6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 923aad5d94d9ad0920d8a18a7863a56545d89f91. --- .../PreferencesWindowController.swift | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/ShadowsocksX-NG/PreferencesWindowController.swift b/ShadowsocksX-NG/PreferencesWindowController.swift index 883af37..b8deeb2 100644 --- a/ShadowsocksX-NG/PreferencesWindowController.swift +++ b/ShadowsocksX-NG/PreferencesWindowController.swift @@ -168,23 +168,16 @@ class PreferencesWindowController: NSWindowController } @IBAction func duplicate(_ sender: Any) { - var copyCount = 0 - for (_, toDuplicateIndex) in profilesTableView.selectedRowIndexes.enumerated() { - print(profileMgr.profiles.count) - let profile = profileMgr.profiles[toDuplicateIndex + copyCount] - let duplicateProfile = profile.copy() as! ServerProfile - duplicateProfile.uuid = UUID().uuidString - profileMgr.profiles.insert(duplicateProfile, at:toDuplicateIndex + copyCount) - - profilesTableView.beginUpdates() - let index = IndexSet(integer: toDuplicateIndex + copyCount) - profilesTableView.insertRows(at: index, withAnimation: .effectFade) - self.profilesTableView.scrollRowToVisible(toDuplicateIndex + copyCount) - self.profilesTableView.selectRowIndexes(index, byExtendingSelection: false) - profilesTableView.endUpdates() - - copyCount += 1 - } + let profile = profileMgr.profiles[profilesTableView.clickedRow] + let duplicateProfile = profile.copy() as! ServerProfile + duplicateProfile.uuid = UUID().uuidString + profileMgr.profiles.insert(duplicateProfile, at: profilesTableView.clickedRow+1) + profilesTableView.beginUpdates() + let index = IndexSet(integer: profileMgr.profiles.count-1) + profilesTableView.insertRows(at: index, withAnimation: .effectFade) + self.profilesTableView.scrollRowToVisible(profilesTableView.clickedRow+1) + self.profilesTableView.selectRowIndexes(index, byExtendingSelection: false) + profilesTableView.endUpdates() updateProfileBoxVisible() }