From 6a6c41732d09b8494497c610caa2ce62ca87d7d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Astori?= Date: Tue, 8 Mar 2016 01:50:52 -0500 Subject: [PATCH] Make sure highlight lookup stops as soon as a candidate is detected --- src/plugins/irc-events/message.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/plugins/irc-events/message.js b/src/plugins/irc-events/message.js index 06ffeef8..85ffed54 100644 --- a/src/plugins/irc-events/message.js +++ b/src/plugins/irc-events/message.js @@ -38,14 +38,11 @@ module.exports = function(irc, network) { var self = (data.from.toLowerCase() === irc.me.toLowerCase()); - var highlight = false; - if (!self) { // Self messages should never be highlighted - textSplit.forEach(function(w) { - if (w.replace(/^@/, "").toLowerCase().indexOf(irc.me.toLowerCase()) === 0) { - highlight = true; - } - }); - } + // Self messages are never highlighted + // Non-self messages are highlighted as soon as the nick is detected + var highlight = !self && textSplit.some(function(w) { + return (w.replace(/^@/, "").toLowerCase().indexOf(irc.me.toLowerCase()) === 0); + }); if (chan.id !== client.activeChannel) { chan.unread++;