From b05f82e2310284165d4bdcbde729be0c3fff34b0 Mon Sep 17 00:00:00 2001
From: Thomas Hopkins <thomchop@users.noreply.github.com>
Date: Wed, 2 Nov 2016 03:47:12 -0700
Subject: PLT-4098 Don't show @mention suggestions if word chars immediately
 precede at sign (#4399)

* PLT-4098 Don't show @mention suggestions if word chars immediately precede at sign

* PLT-4098 Simplify detection of word chars preceding @mentions
---
 webapp/components/suggestion/at_mention_provider.jsx | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'webapp/components/suggestion/at_mention_provider.jsx')

diff --git a/webapp/components/suggestion/at_mention_provider.jsx b/webapp/components/suggestion/at_mention_provider.jsx
index d4f441f98..d1a03deb5 100644
--- a/webapp/components/suggestion/at_mention_provider.jsx
+++ b/webapp/components/suggestion/at_mention_provider.jsx
@@ -112,7 +112,7 @@ export default class AtMentionProvider {
     handlePretextChanged(suggestionId, pretext) {
         clearTimeout(this.timeoutId);
 
-        const captured = (/@([a-z0-9\-\._]*)$/i).exec(pretext.toLowerCase());
+        const captured = (/(?:^|\W)@([a-z0-9\-\._]*)$/i).exec(pretext.toLowerCase());
         if (captured) {
             const prefix = captured[1];
 
@@ -146,7 +146,7 @@ export default class AtMentionProvider {
                         AppDispatcher.handleServerAction({
                             type: ActionTypes.SUGGESTION_RECEIVED_SUGGESTIONS,
                             id: suggestionId,
-                            matchedPretext: captured[0],
+                            matchedPretext: `@${captured[1]}`,
                             terms: mentions,
                             items: users,
                             component: AtMentionSuggestion
-- 
cgit v1.2.3-1-g7c22

