Skip to content

Commit

Permalink
Update TextViewModel.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
humdrum committed Jul 11, 2023
1 parent 981eb24 commit 1c1ff83
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions Examples/TextEditorApp/TextEditorApp/TextEditor/TextViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,17 @@ class TextViewModel {

var textChanges = [TextOperation]()

event.value.forEach { changeInfo in
changeInfo.operations.forEach {
if let op = $0 as? SelectOpInfo {
let range: NSRange

if op.from <= op.to {
range = NSRange(location: op.from, length: op.to - op.from)
} else {
range = NSRange(location: op.to, length: op.from - op.to)
}

textChanges.append(.select(range: range, actorID: changeInfo.actorID ?? ""))
event.value.operations.forEach {
if let op = $0 as? SelectOpInfo {
let range: NSRange

if op.from <= op.to {
range = NSRange(location: op.from, length: op.to - op.from)
} else {
range = NSRange(location: op.to, length: op.from - op.to)
}

textChanges.append(.select(range: range, actorID: event.value.actorID ?? ""))
}
}

Expand Down

0 comments on commit 1c1ff83

Please sign in to comment.