Skip to content

Commit

Permalink
Run autocorrect
Browse files Browse the repository at this point in the history
  • Loading branch information
ra1028 committed Mar 29, 2019
1 parent dccf90e commit 7368c34
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import DifferenceKit
final class ShuffleEmoticonViewController: NSViewController {
@IBOutlet private weak var collectionView: NSCollectionView!
@IBOutlet private weak var tableView: NSTableView!

private var data = (0x1F600...0x1F647).compactMap { UnicodeScalar($0).map(String.init) }
private var dataInput: [String] {
get { return data }
Expand All @@ -22,7 +22,7 @@ final class ShuffleEmoticonViewController: NSViewController {
@IBAction func shufflePress(_ button: NSButton) {
dataInput.shuffle()
}

override func awakeFromNib() {
super.awakeFromNib()

Expand All @@ -34,11 +34,11 @@ extension ShuffleEmoticonViewController: NSCollectionViewDataSource {
func numberOfSections(in collectionView: NSCollectionView) -> Int {
return 1
}

func collectionView(_ collectionView: NSCollectionView, numberOfItemsInSection section: Int) -> Int {
return data.count
}

func collectionView(_ collectionView: NSCollectionView, itemForRepresentedObjectAt indexPath: IndexPath) -> NSCollectionViewItem {
let item = collectionView.makeItem(withIdentifier: EmoticonCollectionViewItem.itemIdentifier, for: indexPath) as! EmoticonCollectionViewItem
item.emoticon = data[indexPath.item]
Expand All @@ -50,7 +50,7 @@ extension ShuffleEmoticonViewController: NSTableViewDataSource, NSTableViewDeleg
func numberOfRows(in tableView: NSTableView) -> Int {
return data.count
}

func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
let view = tableView.makeView(withIdentifier: NSTableCellView.itemIdentifier, owner: tableView) as! NSTableCellView
view.textField?.stringValue = data[row]
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ let package = Package(
path: "Tests"
)
]
)
)
3 changes: 2 additions & 1 deletion Sources/Extensions/UIKitExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ public extension UITableView {
private func _performBatchUpdates(_ updates: () -> Void) {
if #available(iOS 11.0, tvOS 11.0, *) {
performBatchUpdates(updates)
} else {
}
else {
beginUpdates()
updates()
endUpdates()
Expand Down
8 changes: 4 additions & 4 deletions Tests/AlgorithmTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ extension AlgorithmTestCase {
M(2, false),
M(4, false),
M(0, true),
M(3, false),
M(3, false)
]

XCTAssertExactDifferences(
Expand Down Expand Up @@ -320,7 +320,7 @@ extension AlgorithmTestCase {
let source2 = [ArraySection<D, Int>]()

let target2 = [
ArraySection(model: D.a, elements: [0]),
ArraySection(model: D.a, elements: [0])
]

XCTAssertExactDifferences(
Expand Down Expand Up @@ -674,12 +674,12 @@ extension AlgorithmTestCase {
func testComplicated8() {
let source = [
ArraySection(model: M(0, false), elements: [M(0, false), M(1, false)]),
ArraySection(model: M(1, false), elements: [M(2, false), M(3, false)]),
ArraySection(model: M(1, false), elements: [M(2, false), M(3, false)])
]

let target = [
ArraySection(model: M(0, false), elements: []),
ArraySection(model: M(1, false), elements: [M(1, true), M(3, false)]),
ArraySection(model: M(1, false), elements: [M(1, true), M(3, false)])
]

XCTAssertReproducible(source: source, target: target)
Expand Down
3 changes: 2 additions & 1 deletion Tests/TestTools.swift
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ func XCTAssertReproducible<C: RangeReplaceableCollection & Equatable>(
let targetElementPath: ElementPath
if let movedTargetElementPath = elementMoveMap[sourceElementPath] {
targetElementPath = movedTargetElementPath
} else {
}
else {
let deleteOffset = elementDeletionMap[sourceElementPath.section].count(in: 0..<sourceElementPath.element)
let insertOffset = elementInsertionMap[sourceElementPath.section].count(in: 0...sourceElementPath.element)
targetElementPath = ElementPath(element: sourceElementPath.element - deleteOffset + insertOffset, section: sourceElementPath.section)
Expand Down

0 comments on commit 7368c34

Please sign in to comment.