Skip to content

Commit d086baf

Browse files
committed
Cleanup
1 parent 0e8d5a5 commit d086baf

File tree

5 files changed

+18
-20
lines changed

5 files changed

+18
-20
lines changed

Sources/DiffableTextKit/Models/Context.swift

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,7 @@ extension Context {
164164
//=------------------------------------------------------------------------=
165165

166166
/// Use this method on view update.
167-
@inlinable public mutating func merge(
168-
_ status: Status, with cache: inout Cache,
167+
@inlinable public mutating func merge(_ status: Status, with cache: inout Cache,
169168
and options: Synchronize) throws -> Update {
170169
var update = Update()
171170
//=--------------------------------------=
@@ -177,10 +176,10 @@ extension Context {
177176
//=--------------------------------------=
178177
// Validation
179178
//=--------------------------------------=
180-
if options.contains(.invariant), update.contains(.value) {
181-
let input = Info.mark(status.value)
182-
let output = Info.mark(next .value)
183-
throw Info(["input \(input) != \(output) output"])
179+
if options.contains(.acyclical), update.contains(.value) {
180+
let input = Info.init([.note(status.value), "[input]"])
181+
let output = Info.init([.note(next .value),"[output]"])
182+
throw Info([.mark("cyclical"), "\(input) != \(output)"])
184183
}
185184
//=--------------------------------------=
186185
// Update x Active == 2
@@ -207,8 +206,7 @@ extension Context {
207206
//=------------------------------------------------------------------------=
208207

209208
/// Use this method on changes to text.
210-
@inlinable public mutating func merge<T>(
211-
_ text: String, in range: Range<Offset<T>>,
209+
@inlinable public mutating func merge<T>(_ text: String, in range: Range<Offset<T>>,
212210
with cache: inout Cache) throws -> Update {
213211
var update = Update()
214212
//=--------------------------------------=
@@ -242,8 +240,8 @@ extension Context {
242240
//=------------------------------------------------------------------------=
243241

244242
/// Use this method on changes to selection.
245-
@inlinable public mutating func merge<T>(
246-
_ selection: Range<Offset<T>>, with options: Resolve) -> Update {
243+
@inlinable public mutating func merge<T>(_ selection: Range<Offset<T>>,
244+
with options: Resolve) -> Update {
247245
var update = Update()
248246
//=--------------------------------------=
249247
// Layout

Sources/DiffableTextKit/Models/Synchronize.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
/// A message describing synchronization behavior.
1515
@frozen public struct Synchronize: OptionSet {
1616

17-
/// Requires input and output values to be equal.
18-
public static let invariant = Self(rawValue: 1 << 0)
17+
/// Requires that input and output values are equal.
18+
public static let acyclical = Self(rawValue: 1 << 0)
1919

2020
//=------------------------------------------------------------------------=
2121

Sources/DiffableTextKit/Utilities/Brrr.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
/// It uses conditional compilation such that it has no size or cost in RELEASE mode.
1717
///
1818
public struct Brrr: Equatable {
19-
19+
2020
public static let dismiss = Self("dismiss")
2121
public static let cancellation = Self("cancellation")
2222
public static let autocorrection = Self("autocorrection")

Sources/DiffableTextKitXUIKit/DiffableTextField.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public struct DiffableTextField<Style: DiffableTextStyle>: UIViewRepresentable {
152152
//=----------------------------------=
153153
// Synchronize
154154
//=----------------------------------=
155-
self.synchronize(.invariant)
155+
self.synchronize(.acyclical)
156156
}
157157

158158
//=--------------------------------------------------------------------=
@@ -258,13 +258,13 @@ public struct DiffableTextField<Style: DiffableTextStyle>: UIViewRepresentable {
258258
//=------------------------------=
259259
self.push(update)
260260
//=----------------------------------=
261-
// Dismiss
261+
// Cyclical
262262
//=----------------------------------=
263-
} catch let reason {
264-
Brrr.unsynchronizable << Info(reason)
265-
Brrr.dismiss << Info(["cyclical view updates are prohibited"])
263+
} catch let cyclical {
264+
Brrr.unsynchronizable << Info(cyclical)
265+
Brrr.dismiss << Info([.mark("cyclical"), "view updates are prohibited"])
266266
//=------------------------------=
267-
// Task
267+
// Dismiss
268268
//=------------------------------=
269269
Task { self.downstream.dismiss() }
270270
}

Tests/DiffableTextKitTests/Models/Synchronize.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ final class SynchronizeTests: XCTestCase {
2323
// MARK: State
2424
//=------------------------------------------------------------------------=
2525

26-
let all: [Synchronize] = [.invariant]
26+
let all: [Synchronize] = [.acyclical]
2727

2828
//=------------------------------------------------------------------------=
2929
// MARK: Tests x Instances

0 commit comments

Comments
 (0)