mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-02-07 14:23:28 +01:00
Fix crashing bug where last entry in folder wasn't correctly calculating its suggested IndexPath.
This commit is contained in:
parent
d020e93807
commit
99e5003806
@ -293,7 +293,7 @@ class MasterViewController: UITableViewController, UndoableCommandRunner {
|
|||||||
|
|
||||||
// If this is a folder and isn't expanded or doesn't have any entries, let the users drop on it
|
// If this is a folder and isn't expanded or doesn't have any entries, let the users drop on it
|
||||||
if destNode.representedObject is Folder && (destNode.numberOfChildNodes == 0 || !expandedNodes.contains(destNode)) {
|
if destNode.representedObject is Folder && (destNode.numberOfChildNodes == 0 || !expandedNodes.contains(destNode)) {
|
||||||
let movementAdjustment = sourceIndexPath > proposedDestinationIndexPath ? 1 : 0
|
let movementAdjustment = sourceIndexPath > destIndexPath ? 1 : 0
|
||||||
return IndexPath(row: destIndexPath.row + movementAdjustment, section: destIndexPath.section)
|
return IndexPath(row: destIndexPath.row + movementAdjustment, section: destIndexPath.section)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,15 +309,26 @@ class MasterViewController: UITableViewController, UndoableCommandRunner {
|
|||||||
let index = sortedNodes.firstIndex(of: draggedNode)!
|
let index = sortedNodes.firstIndex(of: draggedNode)!
|
||||||
|
|
||||||
if index == 0 {
|
if index == 0 {
|
||||||
|
|
||||||
if parentNode.representedObject is Account {
|
if parentNode.representedObject is Account {
|
||||||
return IndexPath(row: 0, section: destIndexPath.section)
|
return IndexPath(row: 0, section: destIndexPath.section)
|
||||||
} else {
|
} else {
|
||||||
return indexPathFor(parentNode)!
|
return indexPathFor(parentNode)!
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
sortedNodes.remove(at: sortedNodes.firstIndex(of: draggedNode)!)
|
|
||||||
let movementAdjustment = sourceIndexPath < proposedDestinationIndexPath ? 1 : 0
|
sortedNodes.remove(at: index)
|
||||||
return indexPathFor(sortedNodes[index - movementAdjustment])!
|
|
||||||
|
let movementAdjustment = sourceIndexPath < destIndexPath ? 1 : 0
|
||||||
|
let adjustedIndex = index - movementAdjustment
|
||||||
|
if adjustedIndex >= sortedNodes.count {
|
||||||
|
let lastSortedIndexPath = indexPathFor(sortedNodes[sortedNodes.count - 1])!
|
||||||
|
return IndexPath(row: lastSortedIndexPath.row + 1, section: lastSortedIndexPath.section)
|
||||||
|
} else {
|
||||||
|
return indexPathFor(sortedNodes[adjustedIndex])!
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user