Skip to content

Commit

Permalink
Fixes caret position not updated (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbs committed Jun 15, 2022
1 parent d4dc10e commit cfedaa8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Sources/Runestone/TextView/TextInput/TextInputView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -598,14 +598,18 @@ final class TextInputView: UIView, UITextInput {
override func paste(_ sender: Any?) {
if let selectedTextRange = selectedTextRange, let string = UIPasteboard.general.string {
let preparedText = prepareTextForInsertion(string)
inputDelegate?.selectionWillChange(self)
replace(selectedTextRange, withText: preparedText)
inputDelegate?.selectionDidChange(self)
}
}

override func cut(_ sender: Any?) {
if let selectedTextRange = selectedTextRange, let text = text(in: selectedTextRange) {
UIPasteboard.general.string = text
inputDelegate?.selectionWillChange(self)
replace(selectedTextRange, withText: "")
inputDelegate?.selectionDidChange(self)
}
}

Expand Down Expand Up @@ -1265,7 +1269,9 @@ extension TextInputView {
return
}
markedRange = markedText.isEmpty ? nil : NSRange(location: range.location, length: markedText.utf16.count)
inputDelegate?.selectionWillChange(self)
replaceText(in: range, with: markedText)
inputDelegate?.selectionDidChange(self)
delegate?.textInputViewDidUpdateMarkedRange(self)
}

Expand Down

0 comments on commit cfedaa8

Please sign in to comment.