diff --git a/prototype/Doubt/Patch.swift b/prototype/Doubt/Patch.swift index 524adb146..c3a67e65f 100644 --- a/prototype/Doubt/Patch.swift +++ b/prototype/Doubt/Patch.swift @@ -74,7 +74,14 @@ extension Patch { extension Patch { /// Returns a function which computes the size of a `patch` as the sum of the sizes of its terms, as computed by `size`. public static func sum(@noescape size: A throws -> Int)(_ patch: Patch) rethrows -> Int { - return try (patch.state.before.map(size) ?? 0) + (patch.state.after.map(size) ?? 0) + switch patch { + case let .Replace(a, b): + return try size(a) + size(b) + case let .Insert(b): + return try size(b) + case let .Delete(a): + return try size(a) + } } /// Returns a function which computes the size of a `patch` as the absolute difference of the sizes of its terms, as computed by `size`.