Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions submodules/TextFormat/Sources/GenerateTextEntities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ private let identifierDelimiterSet: CharacterSet = {
set.insert("/")
return set
}()
private let mentionDelimiterSet: CharacterSet = {
var set = CharacterSet.whitespacesAndNewlines
set.insert("(")
return set
}()
private let externalIdentifierDelimiterSet: CharacterSet = {
var set = identifierDelimiterSet
set.remove(".")
Expand Down Expand Up @@ -329,14 +334,20 @@ public func generateTextEntities(_ text: String, enabledTypes: EnabledEntityType
}
} else if scalar == "@" {
notFound = false
let isMentionBoundary: Bool
if let previousScalar = previousScalar {
isMentionBoundary = mentionDelimiterSet.contains(previousScalar)
} else {
isMentionBoundary = true
}
if let (type, range) = currentEntity {
if case .command = type {
currentEntity = (type, range.lowerBound ..< utf16.index(after: index))
} else {
commitEntity(utf16, type, range, enabledTypes, &entities)
currentEntity = (.mention, index ..< index)
currentEntity = isMentionBoundary ? (.mention, index ..< index) : nil
}
} else {
} else if isMentionBoundary {
currentEntity = (.mention, index ..< index)
}
} else if scalar == "#" {
Expand Down