修复不连续多选删除错误问题

This commit is contained in:
秦宇航
2017-04-15 09:10:42 +08:00
parent f356cd2d5c
commit 3df85772b0

View File

@ -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()
}