From 3310028e76945987d8a0a2e7519a713c351b36ad Mon Sep 17 00:00:00 2001 From: CylonicRaider Date: Mon, 24 Apr 2017 18:53:20 +0200 Subject: [PATCH 1/5] Improve @-mention matching Pings inside parentheses used to be supported and are still used too much to be dismissed. --- client/lib/stores/chat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/lib/stores/chat.js b/client/lib/stores/chat.js index 43a3ddd1..a1e3d5c5 100644 --- a/client/lib/stores/chat.js +++ b/client/lib/stores/chat.js @@ -12,7 +12,7 @@ import hueHash from '../hueHash' const mentionDelim = String.raw`^|$|[,.!?;&<'"\s]|'|"|&` -const mentionFindRe = module.exports.mentionFindRe = new RegExp('(' + mentionDelim + String.raw`)@(\S+?)(?=` + mentionDelim + ')', 'g') +const mentionFindRe = module.exports.mentionFindRe = new RegExp('(' + mentionDelim + String.raw`|[([{])@(\S+?)(?=` + mentionDelim + String.raw`|[)\]}])`, 'g') const storeActions = module.exports.actions = Reflux.createActions([ 'messageReceived', From 82717df2d0423346aec4fa13d2d66275d827b73a Mon Sep 17 00:00:00 2001 From: CylonicRaider Date: Mon, 24 Apr 2017 18:56:13 +0200 Subject: [PATCH 2/5] Adjust the @-mention regex Gotta catch that parenthesis as well! --- client/lib/stores/chat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/lib/stores/chat.js b/client/lib/stores/chat.js index a1e3d5c5..38be7958 100644 --- a/client/lib/stores/chat.js +++ b/client/lib/stores/chat.js @@ -12,7 +12,7 @@ import hueHash from '../hueHash' const mentionDelim = String.raw`^|$|[,.!?;&<'"\s]|'|"|&` -const mentionFindRe = module.exports.mentionFindRe = new RegExp('(' + mentionDelim + String.raw`|[([{])@(\S+?)(?=` + mentionDelim + String.raw`|[)\]}])`, 'g') +const mentionFindRe = module.exports.mentionFindRe = new RegExp('(' + mentionDelim + String.raw`|[([{])@(\S+)(?=` + mentionDelim + String.raw`|[)\]}])`, 'g') const storeActions = module.exports.actions = Reflux.createActions([ 'messageReceived', From a02b9c9f73a957bc41c0c52344df9eb304494677 Mon Sep 17 00:00:00 2001 From: CylonicRaider Date: Mon, 24 Apr 2017 19:09:14 +0200 Subject: [PATCH 3/5] Improve tab completion Now, nicks in parentheses can be completed as well, if an @ sign indicates the start of the nick. --- client/lib/ui/ChatEntry.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/client/lib/ui/ChatEntry.js b/client/lib/ui/ChatEntry.js index 8298f5c1..c70dfc9c 100644 --- a/client/lib/ui/ChatEntry.js +++ b/client/lib/ui/ChatEntry.js @@ -142,6 +142,7 @@ export default React.createClass({ return } + // Scan backwards for beginning of word let wordStart for (wordStart = wordEnd - 1; wordStart >= 0; wordStart--) { if (!charRe.test(text[wordStart])) { @@ -149,10 +150,17 @@ export default React.createClass({ } } wordStart++ - if (text[wordStart] === '@') { - wordStart++ + + // Scan forward for the first @ sign + let mentionStart + for (mentionStart = wordStart; mentionStart < text.length && charRe.test(text[mentionStart]); mentionStart++) { + if (text[mentionStart] == '@') { + wordStart = mentionStart + 1 + break + } } + // Scan forward for end of word for (; wordEnd < text.length; wordEnd++) { if (!charRe.test(text[wordEnd])) { break From e0b25a8e25c40411eecd74386dc97405e828fd9e Mon Sep 17 00:00:00 2001 From: CylonicRaider Date: Mon, 24 Apr 2017 19:14:09 +0200 Subject: [PATCH 4/5] Mollify JS linter I should stock up my sacrifice goats. --- client/lib/ui/ChatEntry.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/lib/ui/ChatEntry.js b/client/lib/ui/ChatEntry.js index c70dfc9c..187a27ef 100644 --- a/client/lib/ui/ChatEntry.js +++ b/client/lib/ui/ChatEntry.js @@ -154,7 +154,7 @@ export default React.createClass({ // Scan forward for the first @ sign let mentionStart for (mentionStart = wordStart; mentionStart < text.length && charRe.test(text[mentionStart]); mentionStart++) { - if (text[mentionStart] == '@') { + if (text[mentionStart] === '@') { wordStart = mentionStart + 1 break } From 54d5a1c025409cbb4247ca43f90d8bb52ef95f60 Mon Sep 17 00:00:00 2001 From: CylonicRaider Date: Wed, 10 May 2017 17:49:59 +0200 Subject: [PATCH 5/5] Correct mention matching regex The greater-than sign would be mangled to >. Euphoria already has enough parser bugs --- client/lib/stores/chat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/lib/stores/chat.js b/client/lib/stores/chat.js index 38be7958..a1e3d5c5 100644 --- a/client/lib/stores/chat.js +++ b/client/lib/stores/chat.js @@ -12,7 +12,7 @@ import hueHash from '../hueHash' const mentionDelim = String.raw`^|$|[,.!?;&<'"\s]|'|"|&` -const mentionFindRe = module.exports.mentionFindRe = new RegExp('(' + mentionDelim + String.raw`|[([{])@(\S+)(?=` + mentionDelim + String.raw`|[)\]}])`, 'g') +const mentionFindRe = module.exports.mentionFindRe = new RegExp('(' + mentionDelim + String.raw`|[([{])@(\S+?)(?=` + mentionDelim + String.raw`|[)\]}])`, 'g') const storeActions = module.exports.actions = Reflux.createActions([ 'messageReceived',