Skip to content

Commit

Permalink
MM-11109 Properly highlight mentions followed by an underscore (matte…
Browse files Browse the repository at this point in the history
  • Loading branch information
hmhealey authored and sudheerDev committed Jul 12, 2018
1 parent 19c0c7d commit d892459
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions utils/text_formatting.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ function highlightCurrentMentions(text, tokens, mentionKeys = []) {
}

// look for self mentions in the text
function replaceCurrentMentionWithToken(fullMatch, prefix, mention) {
function replaceCurrentMentionWithToken(fullMatch, prefix, mention, suffix = '') {
const index = tokens.size;
const alias = `$MM_SELFMENTION${index}`;

Expand All @@ -284,7 +284,7 @@ function highlightCurrentMentions(text, tokens, mentionKeys = []) {
originalText: mention,
});

return prefix + alias;
return prefix + alias + suffix;
}

for (const mention of mentionKeys) {
Expand All @@ -297,7 +297,7 @@ function highlightCurrentMentions(text, tokens, mentionKeys = []) {
flags += 'i';
}

const pattern = new RegExp(`(^|\\W)(${escapeRegex(mention.key)})\\b`, flags);
const pattern = new RegExp(`(^|\\W)(${escapeRegex(mention.key)})(\\b|_+\\b)`, flags);

output = output.replace(pattern, replaceCurrentMentionWithToken);
}
Expand Down

0 comments on commit d892459

Please sign in to comment.