From 309f24e728ee058a706377a71694c45eac419711 Mon Sep 17 00:00:00 2001 From: ayn2op Date: Thu, 21 May 2026 20:37:28 -0400 Subject: [PATCH] refactor(chat): extract isMentionChar predicate --- internal/ui/chat/message_input.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/ui/chat/message_input.go b/internal/ui/chat/message_input.go index 51cc2fb..243cec9 100644 --- a/internal/ui/chat/message_input.go +++ b/internal/ui/chat/message_input.go @@ -385,10 +385,12 @@ func (mi *messageInput) expandMentions(c *discord.Channel, src []byte) []byte { }) } +func isMentionChar(r rune) bool { + return unicode.IsLetter(r) || unicode.IsDigit(r) || r == '_' || r == '.' +} + func (mi *messageInput) tabComplete() tview.Cmd { - posEnd, name, r := mi.GetWordUnderCursor(func(r rune) bool { - return unicode.IsLetter(r) || unicode.IsDigit(r) || r == '_' || r == '.' - }) + posEnd, name, r := mi.GetWordUnderCursor(isMentionChar) if r != '@' { return mi.stopTabCompletion() } @@ -438,9 +440,7 @@ func (mi *messageInput) tabComplete() tview.Cmd { } func (mi *messageInput) tabSuggest() tview.Cmd { - _, name, r := mi.GetWordUnderCursor(func(r rune) bool { - return unicode.IsLetter(r) || unicode.IsDigit(r) || r == '_' || r == '.' - }) + _, name, r := mi.GetWordUnderCursor(isMentionChar) if r != '@' { return mi.stopTabCompletion() }