Skip to content

Commit

Permalink
Fix crash at range bound when endIndex < startIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
TN-Kenneth committed Nov 22, 2019
1 parent a0b6ce2 commit 0b4c88f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Classes/MentionListener.swift
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,9 @@ extension MentionListener /* Private */ {
if searchSpaces {
let startIndex = mentionsTextView.text.utf16.index(mentionsTextView.text.startIndex, offsetBy: location)
let endIndex = mentionsTextView.text.utf16.index(startIndex, offsetBy: NSMaxRange(textView.selectedRange) - location)
mentionString = String(mentionsTextView.text[startIndex ..< endIndex])
if endIndex > startIndex {
mentionString = String(mentionsTextView.text[startIndex ..< endIndex])
}
} else if let stringBeingTyped = stringToSelectedIndex.components(separatedBy: textBeforeTrigger).last,
let stringForMention = stringBeingTyped.components(separatedBy: " ").last,
stringForMention.range(of: trigger, options: .anchored) != nil {
Expand Down

0 comments on commit 0b4c88f

Please sign in to comment.