Skip to content

Commit

Permalink
fix(szweier): only launch mentions list for mentions that haven't yet…
Browse files Browse the repository at this point in the history
… been added szweier#130
  • Loading branch information
TN-Kenneth committed Feb 16, 2020
1 parent c666cea commit 22037f1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Classes/MentionListener.swift
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,10 @@ extension MentionListener /* Internal */ {
options: .backwards,
range: NSRange(location: 0,
length: NSMaxRange(mentionsTextView.selectedRange)))

let mention = mentions |> mentionBeingEdited(at: searchResult.range)
let location = searchResult.range.location
guard location != NSNotFound, location <= mentionsTextView.text.utf16.count else { return }
guard location != NSNotFound, location <= mentionsTextView.text.utf16.count, mention == nil else { return }

showMentionsListWithString(filterString, searchResult.foundString)
}
Expand Down Expand Up @@ -285,7 +287,8 @@ extension MentionListener /* Private */ {
)
filterString = mentionString.filter { ![trigger, "\n"].contains(String($0)) }

if !(cooldownTimer?.isValid ?? false) {
let mention = mentions |> mentionBeingEdited(at: searchResult.range)
if !(cooldownTimer?.isValid ?? false), mention == nil {
stringCurrentlyBeingFiltered = filterString
showMentionsListWithString(filterString, trigger)
}
Expand Down

0 comments on commit 22037f1

Please sign in to comment.