From 3c5d20f8626e8aec2e50ae5d6534762fd18e0c1d Mon Sep 17 00:00:00 2001 From: tophf Date: Wed, 30 Aug 2017 17:50:32 +0300 Subject: [PATCH] proper partial match detection and display in showRegExpTester closes #180 --- edit/edit.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/edit/edit.js b/edit/edit.js index b2f72a7b..237244ab 100644 --- a/edit/edit.js +++ b/edit/edit.js @@ -1816,7 +1816,8 @@ function showRegExpTester(event, section = getSectionForChild(this)) { const rxData = Object.assign({text}, cachedRegexps.get(text)); if (!rxData.urls) { cachedRegexps.set(text, Object.assign(rxData, { - rx: tryRegExp(text), + // imitate buggy Stylish-for-chrome, see detectSloppyRegexps() + rx: tryRegExp('^' + text + '$'), urls: new Map(), })); } @@ -1882,6 +1883,7 @@ function showRegExpTester(event, section = getSectionForChild(this)) { } else { partial.push($element({appendChild: [ icon, + url.substr(0, match.index), $element({tag: 'mark', textContent: match}), url.substr(match.length), ]}));