Skip to content

Commit 851f34a

Browse files
committed
Cleanup.
1 parent b94d36e commit 851f34a

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

Sources/DiffableTextKit/Helpers/Carets.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@
5757
//=------------------------------------------------------------------------=
5858

5959
@inlinable func map<T>(caret: (Bound) -> T) -> Carets<T> {
60+
//=--------------------------------------=
61+
// MARK: Return
62+
//=--------------------------------------=
6063
self.map(lower: caret, upper: caret)
6164
}
6265

Sources/DiffableTextKit/Helpers/Field.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ extension Field {
7777
//=--------------------------------------=
7878
// MARK: Values
7979
//=--------------------------------------=
80-
let selection = indices(at: selection)
80+
let selection = indices(at: selection) // translate positions to indices
8181
let momentum = momentum ? Directions(from: self.selection, to: selection) : .none
8282
//=--------------------------------------=
8383
// MARK: Update
@@ -86,17 +86,17 @@ extension Field {
8686
}
8787

8888
@inlinable mutating func update(selection: Carets<Index>, momentum: Directions = .none) {
89+
switch selection {
8990
//=--------------------------------------=
9091
// MARK: Accept Max Value
9192
//=--------------------------------------=
92-
if selection == Carets.unchecked((snapshot.startIndex, snapshot.endIndex)) {
93-
return self.selection = selection
94-
}
93+
case .unchecked((snapshot.startIndex, snapshot.endIndex)): self.selection = selection
9594
//=--------------------------------------=
9695
// MARK: Update
9796
//=--------------------------------------=
98-
self.selection = selection.map(
97+
default: self.selection = selection.map(
9998
lower: { snapshot.caret(from: $0, towards: momentum.lowerBound, preferring: .forwards) },
10099
upper: { snapshot.caret(from: $0, towards: momentum.upperBound, preferring: .backwards) })
100+
}
101101
}
102102
}

Sources/DiffableTextKit/Support/Lock.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public final class Lock {
3131
//=------------------------------------------------------------------------=
3232

3333
@inlinable public var isLocked: Bool {
34-
_isLocked
34+
self._isLocked
3535
}
3636

3737
//=------------------------------------------------------------------------=

0 commit comments

Comments
 (0)