Fix crash when ending dictation in Compose CW field

Closes #116
This commit is contained in:
Shadowfacts 2020-10-24 11:26:29 -04:00
parent 8c4ef3caa6
commit 62a9535394
Signed by untrusted user: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 4 additions and 0 deletions

View File

@ -147,6 +147,10 @@ struct ComposeContentWarningTextField: UIViewRepresentable {
let selectedRangeStartUTF16 = textField.offset(from: textField.beginningOfDocument, to: selectedRange.start)
let cursorIndex = text.utf16.index(text.startIndex, offsetBy: selectedRangeStartUTF16)
guard cursorIndex != text.startIndex else {
return nil
}
var lastWordStartIndex = text.index(before: cursorIndex)
while true {
let c = text[lastWordStartIndex]