From 82ecd9fdd51a4dbc04278d1f166b13f37a364e2d Mon Sep 17 00:00:00 2001 From: Penar Musaraj Date: Thu, 6 May 2021 11:37:05 -0400 Subject: [PATCH] DEV: tiny refactor in watched words (#12969) --- .../engines/discourse-markdown/watched-words-replace.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/watched-words-replace.js b/app/assets/javascripts/pretty-text/engines/discourse-markdown/watched-words-replace.js index 7c358d13cf2..c44d5cfe8da 100644 --- a/app/assets/javascripts/pretty-text/engines/discourse-markdown/watched-words-replace.js +++ b/app/assets/javascripts/pretty-text/engines/discourse-markdown/watched-words-replace.js @@ -11,16 +11,14 @@ function findAllMatches(text, matchers, useRegExp) { if (useRegExp) { const maxMatches = 100; - let index = 0; + let count = 0; matchers.forEach((matcher) => { let match; while ( (match = matcher.pattern.exec(text)) !== null && - index < maxMatches + count++ < maxMatches ) { - index++; - matches.push({ index: match.index, text: match[0],