fix(composer): accept combining marks in @mention regex

NFD nicknames are base letters plus \p{M}; the old \p{L}-only pattern
stopped before the accent so NFC peer lookup never saw a match.
This commit is contained in:
Taksh 2026-08-03 17:49:29 +05:30
parent 89b449a8a1
commit 7162d3f451
2 changed files with 6 additions and 1 deletions

View File

@ -41,7 +41,9 @@ final class MessageFormattingEngine {
enum Patterns {
static let hashtag = SafeRegex.compile("#([a-zA-Z0-9_]+)")
static let mention = SafeRegex.compile("@([\\p{L}0-9_]+(?:#[a-fA-F0-9]{4})?)")
// Include \p{M} so NFD nicknames (base letter + combining mark) still
// parse as one mention token; NFC forms are covered by \p{L} alone.
static let mention = SafeRegex.compile("@([\\p{L}\\p{M}0-9_]+(?:#[a-fA-F0-9]{4})?)")
static let cashu = SafeRegex.compile("\\bcashu[AB][A-Za-z0-9._-]{40,}\\b")

View File

@ -116,6 +116,9 @@ final class ChatComposerCoordinator {
}
func parseMentions(from content: String) -> [String] {
// Canonicalize before matching so NFD typed text and NFC peer tokens
// share one codepoint sequence (regex also accepts combining marks).
let content = content.precomposedStringWithCanonicalMapping
let regex = ChatViewModel.Patterns.mention
let nsContent = content as NSString
let matches = regex.matches(