@@ -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}
0 commit comments